The coding problem in vim

Source: Internet
Author: User
Tags coding standards locale

Resolution of the coding problem:

    • ANSI format encoding:

ANSI code (AMERICAN National Standards Institute), Chinese: Standard code for the American Standards Institute.
Definition: Different countries and regions have set different standards, resulting in GB2312, BIG5, JIS and other coding standards. These use 2 bytes to represent a character of a variety of Chinese character extension encoding, called ANSI encoding.
Bug with ANSI encoding method:
When all the characters in the TXT document are in C0≤AA (the first byte) ≤df 80≤BB (the second byte) ≤BF this range, Notepad cannot confirm the format of the document, and does not automatically "Display" in accordance with the UTF-8 format. and "Unicom" is C1 AA CD A8, just in the upper area, so it can not appear normally.

    • UTF-8 format encoding:

UTF-8 (8-bit Unicode Transformation Format) is a variable-length character encoding for Unicode, also known as the Universal Code. Created by Ken Thompson in 1992. It is now standardized to RFC 3629. UTF-8 encodes Unicode characters in 1 to 4 bytes.


Basic knowledge of 1.vim coding:
encoding--This option enables the use of buffered text (the file you are editing), registers, Vim script files, and so on. You can think of the ' encoding ' option as a setting for the internal operating mechanism of Vim.
fileencoding--This option is the type of encoding that VIM uses when writing to a file.
termencoding--This option represents the encoding type that is used by the output to the customer terminal (term).
The Fileencodings:vim automatically detects the sequential list of fileencoding, which detects the character encoding of the file to be opened, starting with the character encoding it lists, and sets the fileencoding to the final detected character encoding method.
It is therefore best to place Unicode encoding at the top of this list, Latin1 Latin encoding to the last side. Fileencodings=ucs-bom,utf-8,default,latin1

2, the default value for this 3 variable:
encoding--is the same as the current locale of the system, so when editing a file, consider the current locale, otherwise you will have more to set up.
Fileencoding--vim automatically recognizes the encoding when the file is opened, and the fileencoding is the recognized value. Empty saves the file with encoding encoding, and if the encoding is not modified, that value is the current locale of the system.
termencoding--the default null value, which is the output to the terminal does not encode the conversion.

3. For ANSI Software . When using terminal login server under Windows, we want to confirm that our Windows system default code page is cp936 (Chinese Windows default), on the other hand to confirm the termencoding= cp936 of vim setting.

The coding problem in vim

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.