Hi everbody. I''m at my wit''s end with a tiny bug in my Rails app. The UK pound symbol (?) is being converted to a question mark (?) somewhere when I save my models. Here''s all the information I can think of. * Constructing a model containing a ?-sign and displaying its contents works fine. * Saving a ?-sign into the database on the mysql command line and retrieving it is fine. * Constructing a model containing a ?-sign and saving it to the database results in the ''?'' being saved to the database instead of the ?-sign. * Everything is working fine on my development system, but the problem occurs on the production server. * Both servers are using MySQL. * The ? symbol appears in all variants of ISO8859 but not in ASCII. * The application in question is running at http://owl.me.uk/ and and example of such a model that should contain a ?-sign is http://owl.me.uk/blog/141 . * I have tried setting the charsets of the table in question to both latin1 and utf-8 to no avail. Has anyone come across anything like this before? Does Rails try to guess the encoding of the DB and rewrite the contents of models before saving them? Can anyone suggest anywhere else I should be looking? -- Posted via http://www.ruby-forum.com/.
Jonathan Conway
2006-May-09 21:17 UTC
[Rails] Re: GBP/pound sign being converted to question mark
Take a look at http://wiki.rubyonrails.com/rails/pages/HowToUseUnicodeStrings I had a similar problem which was caused by data that unfortunately was not in UTF-8 and was scraped from various sources including old windows spreadsheets etc. I had to clean it up and also set the char set in the content type header from an after filter within the controller. Cheers Jonathan ------- http://www.agileevolved.com Rich wrote:> Hi everbody. I''m at my wit''s end with a tiny bug in my Rails app. The UK > pound symbol (?) is being converted to a question mark (?) somewhere > when I save my models. Here''s all the information I can think of. > > * Constructing a model containing a ?-sign and displaying its contents > works fine. > * Saving a ?-sign into the database on the mysql command line and > retrieving it is fine. > * Constructing a model containing a ?-sign and saving it to the database > results in the ''?'' being saved to the database instead of the ?-sign. > * Everything is working fine on my development system, but the problem > occurs on the production server. > * Both servers are using MySQL. > * The ? symbol appears in all variants of ISO8859 but not in ASCII. > * The application in question is running at http://owl.me.uk/ and and > example of such a model that should contain a ?-sign is > http://owl.me.uk/blog/141 . > * I have tried setting the charsets of the table in question to both > latin1 and utf-8 to no avail. > > Has anyone come across anything like this before? Does Rails try to > guess the encoding of the DB and rewrite the contents of models before > saving them? Can anyone suggest anywhere else I should be looking? >