首页 > 网络科技 > CentOS设置文件字符编码的方法

CentOS设置文件字符编码的方法

来源:好再见网 2016-12-24 10:22:53

  字符编码(英语:Character encoding)字集码是把字符集中的字符编码为指定集合中某一对象(例如:比特模式、自然数序列、8位组或者电脉冲),以便文本在计算机中存储和通过通信网络的传递。常见的例子包括将拉丁字母表编码成摩斯电码和ASCII。其中,ASCII将字母、数字和其它符号编号,并用7比特的二进制来表示这个整数。通常会额外使用一个扩充的比特,以便于以1个字节的方式存储。

  1、查看文件字符编码

  ###using file command###

  [root@ipython report]# file --mime-encoding analysis.csv

  analysis.csv: utf-8

  ###using vim command###

  [root@ipython report]# vim analysis.csv

  :set fileencoding

  fileencoding=utf-8

  2、设置文件字符编码

  ####using iconv command####

  syntax:

  iconv -f old_encoding -t new_encoding filename

  ###example###

  [root@ipython report]# iconv -f utf-8 -t gbk analysis.csv > new_analysis.csv

  ###using vim command###

  :set fileencoding=gbk

  :wq!

本文标签:

分享:

扫一扫在手机阅读、分享本文