Solve the Problem of garbled Chinese characters After CentOS on the ssh Terminal

Source: Internet
Author: User
Tags i18n

Solve the Problem of garbled Chinese characters After CentOS on the ssh Terminal

Today, we will help our students solve the problem of garbled Chinese characters. This is a headache for Linux users in China. Most Linux distributions are dominated by English, and English is more versatile and stable than Chinese, there are also a few strange bugs. Therefore, we strongly recommend that you use an English system.

We know that our operating system does not matter the Chinese and English versions. Both windows and Linux have the same kernel in the world when the system is released. The system shows us whether it is English or Chinese, it depends entirely on the Language Pack you selected. When installing and using different countries, people in different countries select their own language packs. The language in the application is not completely written. It calls the relevant language based on the system settings, once an application is written, it can be used by users in different countries around the world on the mother tongue interface. This is called internationalization (International), or i18n for short. This is also the future trend of software development.

If I have installed different language packs and different fonts on the system, how does the system determine the language interface I want and call the relevant fonts? What files and variables are under control in the system?

You can use the locale command to view the default character set used by the current system.

# Locale

In the redHat/CentOS system, the default language file used by the system is/etc/sysconfig/i18n. If a Chinese system is installed by default, the content of i18n is as follows:

LANG = "zh_CN.UTF-8" SYSFONT = "latarcyrheb-sun16" SUPPORTED = "zh_CN.UTF-8: zh_CN: zh"

The LANG variable is short for language. A user with a slight English base can see that this variable determines the default language of the system, that is, the system menu, the tool bar language of the program, and the default language of the input method. SYSFONT is short for system font and determines which font is used by default. The SUPPORTED variable determines the language SUPPORTED by the system, that is, the language that the system can display. It should be noted that because the computer originated from the English-speaking country, no matter what you set these variables, English is always supported by default, and no matter what font you use, the English font is always included.

How can I display Chinese characters?

1. The Chinese Language Pack must be installed in the system.

# Yum-ygroupinstallchinese-support

2. We have to set the corresponding character set if only a Language Pack is available.

# Temporary effect # exportLANG = "zh_CN.UTF-8" # Set to Chinese # exportLANG = "en_US.UTF-8" # Set to English, I prefer this exportLANG = C # permanent effect, edit/etc/sysconfig/i18n (preferably reboot) LANG = "zh_CN.UTF-8" ##or, edit the/etc/profile configuration file, add the following row exportLANG = "zh_CN.UTF-8" # reload #. /etc/profile # view the current character set # echo $ LANG

Well, after the above settings, the terminal should be able to display Chinese characters.

3. ssh remote terminal garbled

If the SSH terminal is still garbled, we also need to set the terminal software encoding.

Xshell:

SecureCRT:

4. What if the terminal is still garbled Chinese?

Set the SSH software and select a Chinese font.

Linux <---> files need to be modified between Windows and garbled characters.

Chinese characters are often garbled after being copied .. The reason is that the default file format in Windows is GBK (gb2312), while Linux is generally a UTF-8. The tedious method is to use a program in windows to convert the content to the UTF-8 encoding format, but it is quite troublesome, and a file is transferred back. Next we will introduce how to solve this problem once and for all in Linux, view the file encoding and how to convert the file encoding.

To avoid these problems, the best method is uniform encoding. All text files are stored in UTF8 format. Do not use word or notepad in windows. Sublime text or notepad ++ is recommended.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.