Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ASCII-8BIT and UTF-8 hell

#4684

MySQL drive does not recognize nor enforce UTF-8 encoding for Ruby 1.9. There is a problem with MySQL text and varchar fields for Rails3 and Ruby 1.9. They are not correctly encoded. Instead of UTF-8 they come as ASCII-8BIT, binary data, and when it is mixed with other UTF-8 text, Rails will raise an exception.

field = MyModel.first.field

field.encoding # => ASCII-8BIT

currently it has to dirty fix:

field = MyModel.first.field.force_encoding('UTF-8').encoding # => UTF-8

The patch enforce UTF-8 encoding for Active Record and MySQL.

Reported by Jaroslaw Zabiello · May 24th, 2010 @ 06:26 PM

State: duplicate
Milestone: none
Assigned to: nobody
Importance: Low