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

**URL:** <https://www.ruby-forum.com/t/encoding-problems-with-rails-3-ruby-1-9-1-big-surprise/190970>\
**Category:** Rails\
**Created:** [July 1, 2010, 9:10pm UTC](https://www.ruby-forum.com/t/encoding-problems-with-rails-3-ruby-1-9-1-big-surprise/190970 "2010-07-01T21:10:58Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![cult\_hero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e56c9b/32.png) [@cult\_hero](https://www.ruby-forum.com/u/cult_hero)\
**Post date:** [July 5, 2010, 12:43pm UTC](https://www.ruby-forum.com/t/encoding-problems-with-rails-3-ruby-1-9-1-big-surprise/190970/21 "2010-07-05T12:43:04Z")

</div>

On Mon, Jul 5, 2010 at 3:02 AM, Fernando P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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](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

---

<div class="post-metadata">

**Author:** ![cult\_hero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e56c9b/32.png) [@cult\_hero](https://www.ruby-forum.com/u/cult_hero)\
**Post date:** [July 5, 2010, 1:14pm UTC](https://www.ruby-forum.com/t/encoding-problems-with-rails-3-ruby-1-9-1-big-surprise/190970/22 "2010-07-05T13:14:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cult\_hero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e56c9b/32.png) [@cult\_hero](https://www.ruby-forum.com/u/cult_hero)\
**Post date:** [July 5, 2010, 1:51pm UTC](https://www.ruby-forum.com/t/encoding-problems-with-rails-3-ruby-1-9-1-big-surprise/190970/23 "2010-07-05T13:51:12Z")

</div>

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/](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.

---

<div class="post-metadata">

**Author:** ![cult\_hero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e56c9b/32.png) [@cult\_hero](https://www.ruby-forum.com/u/cult_hero)\
**Post date:** [July 5, 2010, 1:01pm UTC](https://www.ruby-forum.com/t/encoding-problems-with-rails-3-ruby-1-9-1-big-surprise/190970/24 "2010-07-05T13:01:48Z")

</div>

On Mon, Jul 5, 2010 at 3:16 AM, Fernando P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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

–

---

<div class="post-metadata">

**Author:** ![cult\_hero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e56c9b/32.png) [@cult\_hero](https://www.ruby-forum.com/u/cult_hero)\
**Post date:** [July 20, 2010, 2:21pm UTC](https://www.ruby-forum.com/t/encoding-problems-with-rails-3-ruby-1-9-1-big-surprise/190970/25 "2010-07-20T14:21:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cult\_hero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e56c9b/32.png) [@cult\_hero](https://www.ruby-forum.com/u/cult_hero)\
**Post date:** [July 20, 2010, 3:14pm UTC](https://www.ruby-forum.com/t/encoding-problems-with-rails-3-ruby-1-9-1-big-surprise/190970/26 "2010-07-20T15:14:31Z")

</div>

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](https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/4807-error-encodingundefinedconversionerror-xc3-from-ascii-8bit-to-utf-8)

[Previous page](https://www.ruby-forum.com/t/encoding-problems-with-rails-3-ruby-1-9-1-big-surprise/190970.md?page=1)
