<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