| layout | toc_group | link_title | permalink |
|---|---|---|---|
docs-experimental |
ruby |
Setting up a UTF-8 Locale |
/reference-manual/ruby/UTF8Locale/ |
You need a UTF-8 locale to run some Ruby applications. For example, we have found that RubyGems and ruby/spec need such a locale.
This is not needed if the $LANG environment variable is already set and:
localeshows no ="C" and no warning.
Instead, all values should be "en_US.UTF-8" or other regions but still .UTF-8.
export LANG=en_US.UTF-8The Ubuntu version of locale-gen supports arguments, so it is easy:
sudo apt-get install -y locales
sudo locale-gen en_US.UTF-8
export LANG=en_US.UTF-8Debian and other non-Ubuntu do not support locale-gen arguments.
Instead you need to modify /etc/locale.gen:
# Uncomment the en_US.UTF-8 line in /etc/locale.gen
sudo sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen
# locale-gen generates locales for all uncommented locales in /etc/locale.gen
sudo locale-gen
export LANG=en_US.UTF-8For Dockerfile's:
# Uncomment the en_US.UTF-8 line in /etc/locale.gen
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen
# locale-gen generates locales for all uncommented locales in /etc/locale.gen
RUN locale-gen
ENV LANG=en_US.UTF-8