Linux下打开windows中文文本乱码问题
2024-08-29 14:57:18
1. 查看文件的编码方式:file命令
$ file test_file.txt
test_file.txt: ISO- text, with very long lines $ file train_model.py
train_model.py: Python script, UTF- Unicode text executable $ file 接口文档.docx
接口文档.docx: Microsoft Word +
但是file命令不太可靠, 一个gb2312编码的文件被判断为ISO-8859
2. 在gedit用指定的编码方式打开文件
打开gedit, 然后File => Open => 左下角的Character Encoding的右边有个下拉列表,选择Add or Remove... => 出现下图所示的设置界面,从左边列表中选择需要的编码方式添加到右边列表
然后在打开文件的时候选定需要的编码方式即可:
3. 转码: iconv命令
$ iconv -f gb2312 -t utf- test_file.txt -o test_file_utf8.txt
$ file test_file_utf8.txt
test_file_utf8.txt: UTF- Unicode text
iconv命令的用法具体如下:
$ iconv --help
Usage: iconv [OPTION...] [FILE...]
Convert encoding of given files from one encoding to another. Input/Output format specification:
-f, --from-code=NAME encoding of original text
-t, --to-code=NAME encoding for output Information:
-l, --list list all known coded character sets Output control:
-c omit invalid characters from output
-o, --output=FILE output file
-s, --silent suppress warnings
--verbose print progress information -?, --help Give this help list
--usage Give a short usage message
-V, --version Print program version Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options. For bug reporting instructions, please see:
<https://bugs.launchpad.net/ubuntu/+source/glibc/+bugs>.
参考:https://www.cnblogs.com/longwaytogo/p/6308703.html
最新文章
- Python开发最常犯错误总结10种
- ASP.NET MVC 4 RC的JS/CSS打包压缩功能 Scripts.Render和Styles.Render
- JSP+Servlet中使用cos.jar进行图片上传(文件上传亦然)
- Eclipse-maven项目发布到tomcat没有附带lib拷贝
- jq实现竞拍倒计时
- winform 两个TreeView间拖拽节点
- win7如何开启和关闭超级管理员账户
- 浅析Android中的消息机制-解决:Only the original thread that created a view hierarchy can touch its views.
- 使用MFC开发有十多年了,结合自身的体会,随便说几句(不能样样都依赖别人,C体系的人,绝对不怕人踢馆)
- ubuntu Linux离线安装软件包
- POJ 3080 Blue Jeans(后缀数组+二分答案)
- [转]Decrypt Any iOS Firmware on Mac, Windows, Linux
- java 获取指定日期
- SpringMVC4+MyBatis+SQL Server2014 基于SqlSession实现读写分离(也可以实现主从分离)
- 201521123026《JAVA程序设计》第11周学习总结
- Nginx 配置对流量、连接和请求的限制
- css初始化标签属性--源码
- tiny4412 --Uboot移植(5) DDR3内存
- [转]tomcat启动报错too low setting for -Xss
- SQL基本练习