How to convert the internal code of text file under Linux operating system

  
There are many softwares under Windows that can be used to convert the encoding of files. For example, converting BIG5 encoding to GB2312 can also be done under linux. This command is iconv. A text file foo.txt whose encoding format is GB2312 is converted into BIG5 internal code. You can use iconv -f GB2312 -t BIG5 foo.txt > foo1.txt. The new file foo1.txt is the inner code of BIG5 internal code. It is BIG5 file foo.txt converted to GB2312 internal code with iconv -f BIG5 -t GB2312 foo.txt >foo2.txt Convert GB2312 internal code file to UTF-8 iconv -f GB2312 -t UTF-8 foo. Txt >foo3.txt Finally, batch conversion, convert all the files in a directory into the inner code we need. Assume that there is foo1.txt foo2.txt foo3.txt.... foon.txt in the current directory is GB2312 The code will make all their special BIG5 internal code, and add a BIG5 as a suffix to create a script gb2312_2_big5.sh, the content is as follows ls *.txt | While read i do iconv -f GB2312 -t BIG5 $i>$i.big5 done After saving, execute sh gb2312_2_big5.sh to complete the conversion

Copyright © Windows knowledge All Rights Reserved