Solve Linux document display Chinese garbled problem and encoding conversion

Source: Internet
Author: User

<title>Solve Linux document display Chinese garbled problem and encoding conversion</title> Solve Linux document display Chinese garbled problem and encoding conversion to enable VI support GBK encoding

Because the default encoding under Windows is GBK, and the default encoding under Linux is UTF-8, opening will become garbled. Therefore, we only need to change the configuration file, so that VI support GBK
Open ~/.vimrc File
Plus

1.let &termencoding=&encoding
2.set fileencodings=utf-8,gbk

Then :wq save and exit
Opening VI again will show normal.

Convert other encoded files to Utf-8

In addition, other encoded files can be converted to Utf-8 to view
Open /etc/.vimrc , append the following content

1.set encoding=utf-8 fileencodings=ucs-bom,utf-8,cp936

Where encoding is the default display encoding format for VIM, fileencodings is the encoding format that is detected when Vim opens a file, and this type of encoding is converted to UTF-8 encoding.
This allows vim to automatically identify the file encoding (which automatically identifies the UTF-8 or GBK encoded file), in fact, in accordance with the fileencodings provided by the encoding list to try, if not found the appropriate encoding, the latin-1 (ASCII) encoding opened.

View file encodings directly in Vim
1.:set fileencoding

You can display the file encoding format.

Convert file encoding directly into Vim, such as converting a file to Utf-8 format
1.:set fileencoding=utf-8
Iconv Conversion Code
1.-f encoding -t encoding inputfile
2.#比如将一个UTF-8 编码的文件转换成GBK编码
3.-f GBK -t UTF-8 file1 -o file2

Solve Linux document display Chinese garbled problem and encoding conversion

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.