linux编码转换(Linux code conversion)
linux编码转换(Linux code conversion)
Nginx Tomcat can achieve load balancing
1. test the encoding and conversion of the document, which is good for Chinese support, recommend this. When Chinese characters are less, he doesn't know the code.
In Linux development or system management, garbled is often encountered, the main windows under the Chinese default encoding is GB2312, and under Linux is utf-8. Most of the time involved in transforming communication and windows platform system without encoding, most people are using iconv function library (contained in glib) and the iconv command to perform the encoding conversion, today I want to recommend is a tool enca encoding another shell. It can not only convert encoding, but also view the original encoding of the file, and it is more convenient to use than iconv.
Installing enca under Ubuntu is simple, apt is OK, enca usage follows:
Enca -L zh_CN file checks the encoding of the file
Enca -L zh_CN -x UTF-8 file converts the file encoding to "UTF-8" encoding
Enca -L, zh_CN, -x, UTF-8, < file1 > File2, so if you don't want to overwrite the original file, you can do that
In addition to check the file encoding function, "enca", another advantage is that if you want to convert the file is that it is not an error, encoding, or print results, and "iconv" is wrong. This is more convenient for scripting.
Install enca
Apt-get install enca
Querying the encoding of a single file
Enca index.html
Convert the encoding of a single file
Enca -L none -x UTF-8 index.html
Convert batch file encoding
Find / -type f -name *.htm* cat $1 sort | | | grep -v SVN > files.list
VIM enca_list.sh
Insert the following code:
# /bin/sh!
Cat $1 while read LINE |
Do
Echo $LINE
#enca $LINE
Enca -x UTF-8 $LINE
#enca $LINE
Done
Save after exit
Chmod +x enca_list.sh
Execute script:./enca_list.sh files.list
Source address: /content-detail/140488.html
//========================================
//========================================
2. conversion file name convmv