2

I ran into a problem with a Rails controller where it choked on a Unicode string:

syntax error, unexpected $end, expecting ']' ...conditions => ['url like ?', "%日本%"])

The solution to this problem was to set the encoding at the top of the controller file using

# encoding: UTF-8

Is there any way to set this globally? I keep on getting into trouble by forgetting to set it in files. Alternatively, is there a default somewhere that will make sure that all strings are thought of as Unicode? Are there any problems with setting everything to be Unicode?

2 Answers 2

4

In less than a month, Ruby 2.0 will be released, which will have UTF-8 as the default encoding. Then, you will not need to do that any more.

Sign up to request clarification or add additional context in comments.

Comments

2

You can try setting environment variable RUBYOPT to -Ku value:

export RUBYOPT="-Ku"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.