2
votes

I upgrade my application from Rails 2.3.5 to Rails 3.0.5. One issue in utf8 encoding makes me really confused:

In Rails 2.3.5 version, when I print a Japanese phrase, for example,

    str = "保守性1"        
    p str
    #output: => "\344\277\235\345\256\210\346\200\2471"`

Meanwhile, in Rails 3.0.5 version, the same code will return:

    str = "保守性1"
    p str
    #output: => "保守性1"

I have googled alot but no result. Could you please figure out any possible reason for this issue?

I want to keep the same output as in Rails 2.3.5 version. Any idea is very much appreciated.

Thank you in advance.

1
good question. maybe is due to rails c.Hartator

1 Answers

0
votes

According to http://redmine.ruby-lang.org/issues/show/1238 try to put "magic comment"

# coding: utf-8

to the top of your non-ASCII script.