Solve the problem of checking Chinese garbled characters in Linux system

Source: Internet
Author: User
Tags echo command i18n

A character set is a set of text symbols and their encodings. The commonly used character sets are:
GBK fixed-length DWORD is not an international standard, many supported systems
UTF-8 non-fixed length 1-4 bytes widely supported, MySQL also uses UTF-8
Of course, there are a lot of character sets, and later on in-depth study of this part of the content.

The character set under the ①linux system is controlled by the variable lang.
[Email protected] ~]# echo $LANG
Zh_cn. GB18030

②export lang= "ZH_CN. GB18030 "(Temporary change character set, invalid after reboot)

③ in the/etc/sysconfig/i18n file, the beginning of the line is added: (Configuration is permanently active)
Lang= "ZH_CN. GB18030 "
And put the previous character set line comment "#"
. /ETC/SYSCONFIG/I18N (make changes effective)

④echo ' Export lang= ' ZH_CN. GB18030 "' >>/etc/profile (Global system environment variable configuration file)
Source/etc/profile (Effective)
echo $LANG (View results)

⑤ script used in the work scene, in order to avoid Chinese garbled, sometimes also in the script to change the character set:
#!/bin/sh
Export lang= "ZH_CN. GB18030 "
(Script content)

The ⑥ssh tool (SECURECRT) is aligned with the Linux character set.
In the SECURECRT Session Options dialog box, in the terminal → appearance class, the options in character encoding are consistent with Linux.
The character set used by Linux is "ZH_CN." GB18030 ", the SECURECRT option is set to" default ".

⑦ server and client character set corresponding, garbled can be effectively avoided.
Chinese character set: ZN_CN. GB18030
Character Set Variable: LANG
Character Set configuration file:/etc/sysconfig/i18n

⑧echo command (append of single-line text)
Source and. (The modified variable takes effect)
Export command (SET environment variable)


Refer to: http://www.cnblogs.com/joeyupdo/archive/2013/03/03/2941760.html



A solution to the Chinese garbled characters of vim under Linux

1. Download

available to http://www.vim.org/ Download the latest 7.3 version of Vim source.

2. Installation

before compiling, you must first./configure--help Check the configuration options, where this configuration needs to be added:--enable-multibyte

its role is to support multibyte encoding, which should be important. After the configuration has been made, the nature is made, make install

3. Finally, the VIMRC script is configured

Edit the ~/.VIMRC file, plus the following lines:

Set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
Set Termencoding=utf-8
Set Encoding=utf-8

can be done.


This article is from the "Start from the Heart" blog, please be sure to keep this source http://hao360.blog.51cto.com/5820068/1627924

Solve the problem of checking Chinese garbled characters in Linux system

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.