Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When i upload my rails app via SFTP to production server which is running Ubuntu 10.04 LTS all cyrillic characters in my files look like this:

http://dl.dropbox.com/u/347209/chars.png

As you can see, only parts of words are broken. And because of this rails app doesn't start with syntax error.

Also i'm getting errors like

ActionView::Template::Error (incompatible character encodings: ASCII-8BIT and UTF-8)
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Turns out ruby 1.9 gets default external encoding from environment variable $LANG. On my Ubuntu the following command outputs US-ASCII for some reason:

ruby -e 'puts Encoding.default_external.name'

So i added the following line to the end of /etc/environment file:

LANG = "en_US.UTF-8"

After that i rebooted the server and everything was ok.

If you don't want to change global locales on your system you can also add "magic comment" to the top of your .rb files to force encoding where needed.

# coding: utf-8 
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.