Solution to garbled characters under XShell

Solution to garbled characters under XShell

 

First check whether the language setting of the system is Chinese. 
Enter the command in the terminal: 
# echo $LANG 
If not, you need to modify the environment variable. There are many ways to modify environment variables, and briefly summarize three of the more commonly used ones: 
1> Modifications only for the current terminal and have no effect on other users 
    Input at the command line: 
    # export LANG=ja_JP.UTF-8 
    This modification is only for The current terminal is valid, and it ends when the terminal exits. If you want to check the language and character set supported by the system, you can use the command 
    # locale -a 
2> Modify for the current user to modify the bash configuration file of the current user. When the user logs in, the export enters the LANG variable 
    and first enters the home directory of the current user. For example, the home directory of the root user is /root/, and the home directory of other users is generally /home/username/ 
    # ls -a 
    can see this .bash_profile To hide the file, enter the following command in the terminal: 
    # echo “export LANG=ja_JP.UTF-8” >> .bash_profile 
    The function of this command is to redirect the output of the echo command to the end of .bash_profile 
3> For all users Modify 
    and edit the file /etc/sysconfig/i18n, i18n is the abbreviation of internationalization, which means that there are 18 letters between i and n, which means the internationalization of software. i18n supports multiple languages, but only English and one selected language at the same time, such as English + Chinese, English + Japanese, etc. 
    Modify the value of the LANG variable. The 
    above only modifies the character encoding of the system. But even if the encoding is correct, it may be garbled under xshell. Because xshell also has encoding settings. There is an encoding button on the toolbar of xshell, click this button to select encoding. If it is Japanese garbled characters, you can generally choose Unicode(UTF-8), Japanese(EUC), Japanese(shift-JIS), which one can display correctly without garbled characters and the encoding used for the file to be displayed related. 
    Of course, in addition to the first way to make the settings take effect immediately, the second way and the third way need to restart the shell.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326783588&siteId=291194637