Home > php教程 > PHP开发 > body text

Linux terminal Chinese display garbled characters

高洛峰
Release: 2016-12-15 16:34:43
Original
1569 people have browsed it

This is a problem that worries domestic Linux users. Since most Linux distributions are mainly in English, and English is better than Chinese in terms of versatility and stability, and there are fewer strange BUGs. Therefore, it is strongly recommended to use the English system.

We know that our operating system does not matter the Chinese version or the English version. Whether it is Windows or Linux, when the system is released, the whole world has the same kernel. Whether the system is presented to us in English or Chinese depends entirely on what you choose. Language pack. People from different countries choose the language pack of their own country when installing and using it. The language in the application is not hard-coded. It calls the relevant language according to the system settings. Therefore, an application is written without modification. Users from different countries around the world can use it in their native language interface. This is the so-called internationalization, or i18n for short. This is also the development trend of future software.

So, if I install different language packs and different fonts in the system, how does the system determine the language interface I want and call the relevant fonts? What files and variables in the system control this?

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

Under the RedHat/CentOS system, the file recording the default language used by the system is /etc/sysconfig/i18n. If the default installation is a Chinese system , the content of i18n is as follows:

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

where the LANG variable is the abbreviation of language, slightly Users with a basic knowledge of English can tell at a glance that this variable determines the default language of the system, that is, the system menu, the toolbar language of the program, the default language of the input method, etc. SYSFONT is the abbreviation of system font, which determines which font the system uses by default. The SUPPORTED variable determines the languages ​​supported by the system, that is, the languages ​​the system can display. It should be noted that since computers originated in English-speaking countries, no matter what you set these variables to, English is always supported by default, and no matter what font is used, English fonts are always included.

So how to display Chinese?
1. The system must install the Chinese language pack
# yum -y groupinstall chinese-support

2. Just having the language pack is not enough, we have to set the corresponding character set

## Temporarily effective
# export LANG=" zh_CN.UTF-8" # Set to Chinese
# export LANG="en_US.UTF-8" # Set to English, I prefer this export

## To take effect permanently, edit /etc/sysconfig/i18n (reboot is best) (() /profile

## Check the current character set
# echo $LANG

Okay, after the above settings, Chinese should be able to be displayed on the terminal.

3. The ssh remote terminal is garbled. If the SSH terminal is still garbled, then we also need to set the encoding of the terminal software.

Xshell:


SecureCRT:

Linux terminal Chinese display garbled characters4. What should I do if the terminal is still garbled with Chinese characters?

Set up the SSH software and select a font that supports Chinese.

Linux Windows need to modify files between each other, and then the files will be garbled. Linux terminal Chinese display garbled characters

After copying it, I often find that the Chinese characters are garbled. . The reason is that the default file format in Windows is GBK (gb2312), while Linux is generally UTF-8. The more cumbersome method is to use a program to convert the content into UTF-8 encoding format under Windows, but it is quite troublesome, and it needs to be converted once a file is encountered. Let's introduce how to solve this problem once and for all in Linux, check the encoding of the file and how to convert the file encoding.

In order to avoid these problems, the best way is to use unified encoding. For text files, they are all saved in UTF8 format. Do not use word or notepad under windows. Sublime text, or notepad++ is recommended.

Use SecureCRT to realize two-way communication between WIN7 and Linux and solve the problem of mutual file transfer http://www.linuxidc.com/Linux/2014-08/105412.htm

How to use SecureCRT6.6.2 to log in to the Ubuntu system through SSH http://www.linuxidc.com/Linux/2011-03/33024p4.htm

SecureCRT Connect Ubuntu http://www.linuxidc.com/Linux/2013-06/85824.htm

Ubuntu 12.04 + virtual machine VMware 9 + Secure CRT + EditPlus local C++ development environment construction http://www.linuxidc.com/Linux/2013-05/84820.htm

Use SecureCRT to transfer files between Linux and Windows http://www.linuxidc .com/Linux/2014-08/105413.htm

Ubuntu 14.10 installs SecureCRT 7.3 http://www.linuxidc.com/Linux/2014-10/108709.htm


For more articles related to Linux terminal Chinese displaying garbled characters, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!