This project is archived and is in readonly mode.
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
-
Balazs Nagy February 13th, 2010 @ 08:15 PM
sqlite3-ruby is not yet upgraded to support ruby 1.9. There is, however, a ticket by sqlite3-ruby's developer to get some updates to ActiveRecord's sqlite3 interface some time now: https://rails.lighthouseapp.com/projects/8994/tickets/3790-sqlite3-...
I expect once this will be added to the recent versions of ActiveRecord, the new sqlite3 driver will follow soon with ruby 1.9 encoding support.
-
Benoit Daloze February 14th, 2010 @ 12:32 AM
Hi,
I just tried with mysql, and got the same error.
I tried also with git's version of tenderlove's sqlite3-ruby, but I didn't manage to make it work (LoadError: no such file to load -- sqlite3/sqlite3_native).
mysql tagged, as sqlite3 the string as ASCII-8BUT, which is non-sense.
Isn't it rails3's fault to tag these String like that?
It doesn't look of a hazard both fail the same way ...Thanks for your answer
-
Yaroslav Markin April 10th, 2010 @ 07:49 PM
MySQL driver is buggy as well; There is stuff like http://github.com/brianmario/mysql2, but, actually, this is not a Rails bug but a driver bug.
Latest Postgres binary gem (gem install pg) recognizes UTF-8 just fine.
-
Ryan Bigg April 11th, 2010 @ 10:58 PM
- State changed from new to invalid
Related ticket #3790 committed. This issue is no longer valid.
-
Benoit Daloze April 12th, 2010 @ 09:31 AM
Ok,
Thanks for the answers.
Regards,
B.D.(I spoke of regression because rails 2.3.5 did worked with ruby 1.9 and these encodings)
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
Referenced by
- 4807 ERROR Encoding::UndefinedConversionError: "\xC3" from ASCII-8BIT to UTF-8 Maybe linked with #3947 and #2188 ?