This project is archived and is in readonly mode.

#3947 ✓invalid
Benoit Daloze

incompatible character encodings: UTF-8 and ASCII-8BIT for Rails 3

Reported by Benoit Daloze | February 13th, 2010 @ 10:46 AM

I'm running Rails with 1.9.2(trunk).

This might be a duplicate of #2188, but I didn't have any problem with rails 2.3.5.
So I get this on Rails 3:
"incompatible character encodings: UTF-8 and ASCII-8BIT" Then it shows me the line in the template.

I'm just retrieving a String from a sqlite3 database (this does not happen with I18n YAML files), and the String get tagged of ASCII-8BIT.

Adding str.force_encoding('utf-8') works but it's not really DRY neither convenient.
Changing default internal/external didn't work.

I'm using Haml, but it did fail the same way with Erb.

Why does this 'regression' happen ? I mean 2.3.5 did deal good with that.

Maybe be a config encoding option in application.rb might be interesting, or make everything utf-8 default.

PS: I get the same error on the form around this:
= f.label :date = f.datetime_select :date From when showing select for date have any special character not in ASCII-7BIT ? Looks really weird, because it's another field who's responsible of the encoding mismatch.

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>

Referenced by

Pages