Linux transcoding command line and python implementation, linuxpython
The file copied from windows to linux is garbled today.File, iconvCommand transcoding is enough.
/* If it is implemented through a command line, it is also possible, and to some extent it may be more convenient */
File genghao. cpp/* You can find the approximate encoding type of this file */
Iconv-l/* Check whether our iconv tool supports this encoding, but it does not. Just select a closer one */
Iconv-f XXXX(Original encoding)-T YYY(The encoding you want)Genghao. cpp(Original file)Genhao. cpp(Target file)
 
If you want to learn more about the above instructions, you can refer to blog: http://blog.csdn.net/echoisland/article/details/6660619, which also mentionedFile tools may be misjudged..
As a restless person, a small function can be implemented using different tools. It is convenient to use scripts to implement transcoding. 
What language? In fact, php, python, shell..., and even advanced C ++ and C can be implemented through corresponding file operations and some interfaces. 
 
I want to use python for transcoding. 
 
Import chardet 
 
Fp = open ('genhao. cpp ', 'r + ') 
 
/* Readlines reads the file, in a list of behavior units */ 
Content = '\ n'. join (fp. readlines ()) 
Print content 
/* The file pointer returns to the beginning of the file */ 
Fp. seek (0) 
 
/* Read the entire file */ 
Content = fp. read () 
Print content 
Fp. seek (0) 
 
/* Read 1 row in readline */ 
Tmp = fp. readline () 
While tmp: 
Content + = tmp 
Tmp = fp. readline () 
Print content 
 
/* Determine the file encoding */ 
Charinfo = chardet. detect (content) 
Encoding = charinfo ['encoding'] 
/* Convert to UTF-8 */ 
Content = content. decode (encoding). encode ('utf-8 ') 
Print content 
 
Get it done. Wait for time and write the implementation of other tools.
 
By convention,A sentence: language is just a tool, and ideas and problems are the key points.