views:

91

answers:

1

Somewhere along the line from the DB to the application, this:

sauté

is getting turned into this:

sauté

I'm using Ramaze + Rack + MySQL. I've got a force_encoding plugin set up, so the encoding on the string is UTF-8. If I view the record in the database shell, it's looks fine. The default charset on the table is utf8, and the field itself is "text". The encoding on my database connection is utf8. Also, on my Macbook, everything works great. It's on my Ubuntu server that it's getting mangled. I'm hoping that someone may recognize this and tell me that it's unicode getting turned to ASCII, then back, or something like that.

A: 

Most likely your locale differs. Run the locale command on both and see what's the difference. I assume you see an issue when you get results back from MySQL, which is a common issue with 1.9 according to google results: http://www.google.com/search?q=mysql+ruby+1.9+encoding.

manveru
Both locals are all "en_US.UTF-8". Yeah, I see this from the console too, just grabbing the object and inspecting it.So, here's something interesting. I set Encoding.default_internal to 'UTF-8', which made logging blow up with "'\xC3' from ASCII-8BIT to UTF-8", but it also made any new data going into the DB come out just fine. So, it must be some problem going into the DB, not coming out like I thought. Anyway, I'm happing to turn of SQL logging on production and just call this a win. Ruby 1.9 strings are really killing me.