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

Phemia ·
更新时间:2024-09-21
· 636 次阅读

字符编码(英语: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!



编码 方法 centos 字符 字符编码

需要 登录 后方可回复, 如果你还没有账号请 注册新账号