Various garbled questions

Source: Internet
Author: User
We all know that garbled characters are character set settings. Therefore, we need to understand several concepts about character sets. Www.2cto. comGB2312: The early Chinese character set (GB), with a small font, is not recommended. GBK: The big character that Microsoft developed to make up for the shortcomings of gb2312... we all know that garbled characters are character set settings, so we need to understand several concepts about character sets. Www.2cto.com GB2312: The early Chinese character set of the national standard, the font is small, not recommended. GBK: a big character set developed by Microsoft to make up for gb2312's shortcomings. it is a superset of gb2312 and a windows default character set. it is almost a de facto standard. GB18030: the national standard of the big character set, which has more words than GBK. However, the encoding definition is slightly different from that of GBK. Generally, they are considered compatible. IBM-eucCN: IBM's Chinese character set. AIX defaults to be compatible with GBK, but with fewer words. UTF8: the most comprehensive character set, which can be processed with any uncommon character. it is recommended. CP936: Code Page 936, the Chinese language Code Page in windows. it was first mapped to gb2312 and is now mapped to gbk. The following describes the factors related to character set settings by editing an utf8 file. To process the utf8 file, we should use utf8 in all reading and writing steps to avoid garbled code during automatic program transcoding. 1. set the current environment character set to UTF8 first use the locale charmap command to check the current character set. If not utf8, use locale-a to list the currently available character sets of the system, locate the item that contains utf8, such as the ZH_CN.UTF-8, and then export LANG = ZH_CN.UTF-8 to modify the LANG environment (note case sensitive ), then run the locale charmap command to check again. In most cases, this is OK. If the character set is not changed or changed to another one, use the locale command to check the detailed language settings. then, you will find that some environment variables starting with LC _ are not utf8, manually unset or export utf8. www.2cto.com 2. set character set a of the terminal software) Putty: window → Translation → Remote character set to UTF-8, can also be saved in the session. B) Xshell: Terminal → Translation → Encoding to UTF-8, you can also quickly switch through the Encoding icon on the toolbar, we recommend that you use xshell as a Terminal. C) SecureCRT: Terminal → Appearance → character encoding changed to UTF-8. now we can view utf8 files through cat or write utf8 data into the file through cat> testfile. However, if you use vim to edit the environment variable, you also need to modify the environment variable of vim. 3. VIM ~ /. Vimrc, set fileencodings = UTF-8 (specify vim to open the file with utf8 encoding) and set encoding = UTF-8 (specify vim to output to the terminal with utf8 encoding) in this way, we can use vim to edit the utf8 file, and other character sets are similar to this. However, each modification is troublesome. if it does not contain uncommon words, we can use iconv-f utf8-t gb18030 filename to convert the utf8 file to gb18030 for processing.

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.