Search code examples
mysqlrubyutf-8rackramaze

Can't find out where my Ruby 1.9 string encoding is getting messed up


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.


Solution

  • 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.