This project is archived and is in readonly mode.

#4684 ✓duplicate
Jaroslaw Zabiello

ASCII-8BIT and UTF-8 hell

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

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.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Pages