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

最新文章

  1. Python开发最常犯错误总结10种
  2. ASP.NET MVC 4 RC的JS/CSS打包压缩功能 Scripts.Render和Styles.Render
  3. JSP+Servlet中使用cos.jar进行图片上传(文件上传亦然)
  4. Eclipse-maven项目发布到tomcat没有附带lib拷贝
  5. jq实现竞拍倒计时
  6. winform 两个TreeView间拖拽节点
  7. win7如何开启和关闭超级管理员账户
  8. 浅析Android中的消息机制-解决:Only the original thread that created a view hierarchy can touch its views.
  9. 使用MFC开发有十多年了,结合自身的体会,随便说几句(不能样样都依赖别人,C体系的人,绝对不怕人踢馆)
  10. ubuntu Linux离线安装软件包
  11. POJ 3080 Blue Jeans(后缀数组+二分答案)
  12. [转]Decrypt Any iOS Firmware on Mac, Windows, Linux
  13. java 获取指定日期
  14. SpringMVC4+MyBatis+SQL Server2014 基于SqlSession实现读写分离(也可以实现主从分离)
  15. 201521123026《JAVA程序设计》第11周学习总结
  16. Nginx 配置对流量、连接和请求的限制
  17. css初始化标签属性--源码
  18. tiny4412 --Uboot移植(5) DDR3内存
  19. [转]tomcat启动报错too low setting for -Xss
  20. SQL基本练习

热门文章

  1. 快用Visual Studio(四)- 主题 偏好与快捷键
  2. 谈一谈URL
  3. python中的上下文管理器
  4. 锁(3)-- DB锁
  5. arm-linux-gcc安装使用教程
  6. springmvc+rest整合redis
  7. flask学习(十):模板中访问模型和字典的属性
  8. 1012: [JSOI2008]最大数maxnumber 线段树
  9. Lua学习笔记1,基本数据类型
  10. 虚拟机VMware搭建代码环境