CentOS7ä¿®æ¹æä»¶çå符éå½ä»¤ï¼
iconv -f gbk -t utf-8 -o test2.txt test.txt

æä½æ¥éª¤ï¼
1ãæ¥çç³»ç»å符é
[[email protected] ~]# cat /etc/locale.conf
2ãæ¥çæä»¶å 容(è¿ä¸ªæä»¶æ¯æå¨windowsä¸å建çtxtæä»¶)
[[email protected] ~]# cat test.txt
3ãæ¥çæä»¶å符é
[[email protected] ~]# file -i test.txt
test.txt: text/plain; charset=iso-8859-1
4ãä¿®æ¹å符é(æç §ä¸é¢è·åå°çåç¬¦éæ ¼å¼iso-8859-1è¿è¡ä¿®æ¹)
[r[email protected] ~]# iconv -f iso-8859-1 -t utf-8 -o test1.txt test.txt
5ãæ¥çä¿®æ¹è¿å符éçæä»¶test1.txt(iso-8859-1)
[[email protected] ~]# cat test1.txt
6ãæ¥çtest1.txtæä»¶å符é
[[email protected] ~]# file -i test1.txt
test1.txt: text/plain; charset=utf-8
7ãä¿®æ¹å符é(å 为æç¥éè¿ä¸ªæä»¶æ¯å¨windowsä¸å建çtxtæä»¶ï¼ç´¢æ§å°±å°è¯ç¨gbk转æ¢)
iconv -f gbk -t utf-8 -o test2.txt test.txt
8ãæ¥çä¿®æ¹è¿å符éçæä»¶test2.txt(gbk)
[[email protected] ~]# cat test2.txt
9ãæ¥çtest2.txtæä»¶å符é
[[email protected] ~]# file -i test2.txt
test2.txt: text/plain; charset=utf-8
10ãè³äºä¸ºä»ä¹æç §gbkçæ ¼å¼ä¿®æ¹æ£å¸¸ï¼è使ç¨iso-8859-1çæ ¼å¼ä¿®æ¹æé®é¢ï¼æä¹æçé®ï¼
ä¿®æ¹æä»¶çå符é详ç»å½ä»¤è¯·çä¸é¢ï¼
使ç¨iconvå½ä»¤ä¿®æ¹å符éï¼
[[email protected] ~]# iconv --help
ç¨æ³ï¼ iconv [é项...] [æä»¶...]
转æ¢ç»å®æä»¶çç¼ç ã
è¾å ¥/è¾åºæ ¼å¼è§èï¼
-f, --from-code=åç§° åå§ææ¬ç¼ç
-t, --to-code=åç§° è¾åºç¼ç
ä¿¡æ¯ï¼
-l, --list å举ææå·²ç¥çå符é
è¾åºæ§å¶ï¼
-c ä»è¾åºä¸å¿½ç¥æ æçå符
-o, --output=FILE è¾åºæä»¶
-s, --silent å ³éè¦å
--verbose æå°è¿åº¦ä¿¡æ¯
-?, --help ç»åºè¯¥ç³»ç»æ±å©å表
--usage ç»åºç®è¦çç¨æ³ä¿¡æ¯
-V, --version æå°ç¨åºçæ¬å·
é¿é项çå¼ºå¶æå¯é忰坹坹åºççé项乿¯å¼ºå¶æå¯éçã
For bug reporting instructions, please see:
.
使ç¨fileå½ä»¤æ¥çå符éï¼
[email protected] ~]# file --help
Usage: file [OPTION...] [FILE...]
Determine type of FILEs.
--help display this help and exit
-v, --version output version information and exit
-m, --magic-file LIST use LIST as a colon-separated list of magic
number files
-z, --uncompress try to look inside compressed files
-b, --brief do not prepend filenames to output lines
-c, --checking-printout print the parsed form of the magic file, use in
conjunction with -m to debug a new magic file
before installing it
-e, --exclude TEST exclude TEST from the list of test to be
performed for file. Valid tests are:
ascii, apptype, compress, elf, soft, tar, tokens, troff
-f, --files-from FILE read the filenames to be examined from FILE
-F, --separator STRING use string as separator instead of `:'
-i, --mime output MIME type strings (--mime-type and
--mime-encoding)
--apple output the Apple CREATOR/TYPE
--mime-type output the MIME type
--mime-encoding output the MIME encoding
-k, --keep-going don't stop at the first match
-l, --list list magic strength
-L, --dereference follow symlinks (default)
-h, --no-dereference don't follow symlinks
-n, --no-buffer do not buffer output
-N, --no-pad do not pad output
-0, --print0 terminate filenames with ASCII NUL
-p, --preserve-date preserve access times on files
-r, --raw don't translate unprintable chars to \ooo
-s, --special-files treat special (block/char devices) files as
ordinary ones
-C, --compile compile file specified by -m
-d, --debug print debugging messages
Report bugs to http://bugs.gw.com/