Encoding problems with Rails 3 + Ruby 1.9.1 (big surprise)

On Mon, Jul 5, 2010 at 3:02 AM, Fernando P. [email protected]
wrote:

Now if I remove the magic comment <%# # -- coding: UTF-8 -- %> from
application.html.erb and put Encoding.default_internal = Encoding::UTF_8
at the top of environment.rb, I get the following error:

=> Booting WEBrick
=> Rails 2.3.8 application starting on http://0.0.0.0:3000

[gem_path/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/base.rb:244:in
`read’: “\xC3” on US-ASCII (Encoding::InvalidByteSequenceError)

Actually, I’m actually using bundler but I would put this statement at
the
bottom of the environment.rb.
Also, you can set the internal and the external encodings by doing the
following:

ruby -E <external_encoding>:<internal_encoding>

For example, you could try using something similar to the following:

PassengerRuby <path_to_ruby_executable>/ruby -E utf-8:utf-8

Next, the w3c validator detection is not all that relevant in regards to
how
Ruby processes the file. The
w3c validator will parse the file from top to bottom checking that the
file
syntactically correct. ERB engine
will parse the file looking for relevant tags and replace them
accordingly
with the appropriate HTML.

-Conrad

Thanks for your messages. I’ll dig into them thoroughly. I guess the
LANG is the key.

Do you have a small test case or small application which reproduces the
issue?

-Conrad

Well, my app doesn’t even start up, so there is no better test case to
provide.

All this is just boring. We’re in 2010 now, not 1983.

I stumbled upon
http://rvdh.de/blog/2010/01/06/why-you-cant-run-rails-23-apps-on-ruby-19/
and I’m experiencing the exact same problems.

So I’ll just ditch Ruby 1.9 and get back to 1.8.7 until all this mess
gets fixed and documented.

Thanks for your valuable help.

On Mon, Jul 5, 2010 at 3:16 AM, Fernando P. [email protected]
wrote:

LC_NUMERIC=“C”
LC_MONETARY=“C”
LC_MESSAGES=“C”
LC_ALL=

Have you tried setting the LANG environment for your OS. This is
currently
set within
my environment.

/usr/local/lib/ruby/gems/1.9/gems/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/base.rb:244:in
`read’: “\xC3” on US-ASCII (Encoding::InvalidByteSequenceError)

Any idea?

In regards to Rails 2.3, I’m using 2.3.5 and Rails 2.3.8 as well as the
mysql2 Ruby gem which does UTF-8 by default. Do
you have a small test case or small application which reproduces the
issue?

-Conrad

Hi,

It’s me again. Now running Rails 3 beta4 and Ruby 1.9.1, and that
encoding thing is as I said a gigantic catastrophe! It still does not
work!

I added default_encoding, and it’s as if it doesn’t care about it.

Rails3 beta4 is still bugged. It should be fixed in RC1:
https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/4807-error-encodingundefinedconversionerror-xc3-from-ascii-8bit-to-utf-8