Skip to content

Fix Chinese garbled characters when connecting Ubuntu 22 with MobaXterm

Problem description

When using MobaXterm ssh to remotely log in to Ubuntu22 Desktop, the Chinese characters cannot be displayed normally in the shell terminal, and are displayed in the form of \digit\digit....... At the same time, the Chinese names of the files listed in the SFTP window nearby are displayed normally.

Troubleshooting process

Use locale -a to display the supported languages ​​as follows:

C
C.utf8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IL
en_IL.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
POSIX
zh_CN.utf8
zh_SG.utf8

Theoretically, Chinese should be supported.

Then use the locale command, and the display is as follows:

LANG=
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

It is suspected that the LANG environment variable is not set.

Fix

Set the value of LANG variable in Ubuntu terminal, vi ~/.bashrc, add the following content at the end of the file:

LANG=en_US.UTF-8

Reconnect SSH, everything is back to normal.

Leave a Reply