# shell和vim中乱码原因及消除办法

690人阅读 评论(0)

## 基本概念

### 字符编码[character encoding]

1. 统一一下，双方都使用同一种编码方式。
2. 把对方的内容转换成跟自己的编码方式一致的内容。可以用类似 iconv 这样的工具来完成

## 乱码实战

### vim中显示的乱码问题

1. termencoding

Encoding used for the terminal. This specifies what character encoding the keyboard produces and the display will understand. For the GUI it only applies to the keyboard.

2. encoding

Sets the character encoding used inside Vim. It applies to text in the buffers, registers, Strings in expressions, text stored in the vim info file, etc. Changing this option will not change the encoding of the existing text in vim. The character encoding of files can be different from 'encoding'. This is specified with 'file encoding'. The conversion is done with icon() or as specified with ‘charconvert'

3. fileencoding

Sets the character encoding for the file of this buffer. When 'file encoding' is different from 'encoding', conversion will be done when reading and writing the file.文件自身的编码方式。如果fileencoding和encoding不一致，那么在读取和写入文件时，会对编码方式进行转换。

4. fileencodings

This is a list of character encodings considered when starting to edit an existing file. When a file is read, Vim tries to use the first mentioned character encoding. If an error is detected, the next one in the list is tried. When an encoding is found that works, 'file encoding' is set to it. If all fail, 'file encoding' is set to an empty string, which means the value of 'encoding' is used.
Note that 'fileencodings' is not used for a new file, the global value of 'file encoding' is used instead.

## 推荐阅读

0
0

* 以上用户言论只代表其个人观点，不代表CSDN网站的观点或立场
个人资料
• 访问：324857次
• 积分：2933
• 等级：
• 排名：第12452名
• 原创：22篇
• 转载：129篇
• 译文：1篇
• 评论：45条
文章分类
最新评论