78

简析LINUX下打开windowsTXT文件乱码的问题

 5 years ago
source link: https://www.linuxprobe.com/linux-windowstxt.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
导读  有时候需要在linux下面处理一些windows下生成的txt文件,但在控制台查看的时候经常会出现乱码,这是因为两个操作系统默认使用的字符集是不同的,Linux下使用的字符集是utf-8,而windowsXP使用的是GB3212。

在Linux下要阅读windows生成的txt文件,需要通过iconv进行字符转化

iconv -f gb2312 -t utf8 ./读书笔记.txt > ./new.txt

以上命令的意思是将文件“读书笔记.txt”的字符集由gb2312转换为utf8,并生成新的文件new.txt

转换前:

[tiger506@localhost 文档]$ cat ./读书笔记.txt

����һ����ʼ ��������һ����ʼ �����һ�ʢ���ĵط�[

转换后,查看新生成文件new.txt:

[tiger506@localhost 文档]$ cat ./new.txt

这是一个开始 这是另外一个开始 这是桃花盛开的地方


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK