Since Japanese characters were garbled and displayed in a square (so-called Tofu tofu), set the environment for displaying Japanese.
Ubuntu 16.04.5 LTS Windows10 Vagrant
If you check the environment variable, it is an English environment, so change the environment variable to Japanese
echo $LANG
en_US.UTF-8
Install two Japanese packages (** language-pack-ja-base ** and ** language-pack-ja **) with ** apt **
sudo apt install language-pack-ja-base language-pack-ja
Go home and add the following at the bottom of **. Bashrc **
case $TERM in
linux) LANG=C ;;
*) LANG=ja_JP.UTF-8;;
esac
Commentary The terminal type is set in the environment variable of $ TERM. By the way, ** xterm-256color ** is set in my environment. If the terminal type is ** linux **, the localization is ** C **, otherwise it is in Japanese. When the terminal type is linux, it is the case that the client directly contacts the server instead of using the terminal by SSH connection. In this case, if you use Japanese, the characters will be garbled, so ** C ** is set to create an English environment. If you don't want to touch the server directly, you can just use one line ** LANG = ja_JP.UTF8 **.
Execute **. bashrc ** to reflect
source .bashrc
When you install the Japanese package, a file called ** ja ** will be added to ** /var/lib/locales/supported.d **, so check the contents.
cat /var/lib/locales/supported.d/ja
ja_JP.UTF-8 UTF-8
Display the list of installed locales and confirm that ** ja_JP.utf8 ** is displayed.
locale -a | grep ja
If you check the default locale, it is in English
cat /etc/default/locale
# File generated by update-locale
LANG="en_US.UTF-8"
LANGUAGE="en_US:"
Change the default locale to Japanese. error? A message that seems to be displayed is displayed, but it has been updated properly.
sudo update-locale LANG=ja_JP.UTF-8
*** update-locale: Warning: LANGUAGE ("en_US:") is not compatible with LANG (ja_JP.UTF-8). Disabling it.
Confirm that it has been changed. Japanese was added and English was commented
cat /etc/default/locale
# File generated by update-locale
LANG=ja_JP.UTF-8
#LANGUAGE="en_US:"
In the case of vagrant environment, the character code environment on the Windows side (PowerShell side) may be the cause. If the above does not solve the problem, ↓ https://qiita.com/FmtWeisszwerg/items/ccd34acfb2e88c2fb35f
Recommended Posts