I. Coding problems
Encoding is common for GBK utf-8 Big5 cp936
1, view the current text encoding
: Set Fenc
: Set fileencoding
2, modify the terminal code, you can set up a terminal or in vim
: Set tenc= encoding
: Set Termencoding=utf-8
3. Displays the text in the specified encoding, but does not save it to the file.
: Set enc= encoding
: Set Encoding=utf-8
4, the conversion of the current text encoding for the specified encoding
: Set fenc= encoding
: Set Fileencodings=utf-8, then W (save) can be converted to UTF8 format,
: Set fileencodings=cp936, then W (save) can be converted to ANSI format.
Mode type of text
The generic file type pattern is Dos,unix
1. View the mode type of the current text
: Set FF
2, set to DOS mode, that is, the format of Windows
: Set Ff=dos
3, set to UNIX mode
: Set Ff=unix
:%s/^m//g
Iii. Coding Conversion Tools
1, enconv conversion file encoding, such as to convert a GBK encoded file into UTF-8 encoding
Enconv-l zh_cn-x UTF-8 filename
2, iconv conversion, iconv command format is as follows
Iconv-f ENCODING-T Encoding Inputfile
Iconv-f UTF-8-T GBK file1-o file
Bulk conversion Scripts
#!/bin/bash
If ["$#"!= "2"]; then
echo "Usage: ' basename $ ' dir filter '
exit
fi
dir=$1
filter =$2
echo
$dir-name "$", do
echo "$file"
#iconv-F gbk-t utf8-o $file $file
Iconv-f utf8-t gbk-c-o $file $file done
How to use
~/iconv_shell.sh./*java
3, CONVMV Conversion code
Convmv-f Source code-T new encoding [option] filename
Analog conversion comparison
Convmv-f gbk-t UTF-8 *.mp3
True Conversion command
Convmv-f gbk-t UTF-8--notest *.mp3
4, eNCA automatic recognition conversion
View Current file encoding
Enca-l ZH_CN Ip.txt
Conversion encoding
Enca-l current language-x target encoded file name
Bulk conversions
Enca-l zh_cn-x Utf-8 *