Win using Telnet to Ubuntu under Vim display Chinese as garbled solution ~

Source: Internet
Author: User

1. Several paths:

Ubuntu:/etc/default/locale equivalent to centos:/etc/sysconfig/i18n

Path to VIMRC: ①~/.VIMRC②/ETC/VIM/VIMRC

2. Workaround:

① Adding language support
$sudo vim/var/lib/locales/supported.d/local#
Add the following Chinese character set zh_cn. GBK GBK
Zh_cn. GB2312 GB2312
Zh_cn. GB18030 GB18030
To bring it into effect: $sudo dpkg-reconfigure locales
②vi ~/.VIMRC (if VI/ETC/VIM/VIMRC, do not know why the full screen is the highlight of the shield Word = =!) ③
set fileencodings=utf-8, GBKset termencoding=utf-8, GBK ( Here GBK is my own addition, because the system used is XP,XP internal use of the encoding for gbk,termencoding This field is related to Terminal display encoding)set ENCODING=PRC

3. Basics of encoding in case I forget this someday

There are several options in vim that affect the support for multibyte encoding:①encoding (ENC): encoding is the internal use of Vim encoding, encoding settings will affect the internal vim buffer, message text and so on. In UNIX environment, the default setting of encoding is equal to locale;
The Windows environment will be the same as the current code page. The default setting for encoding in the Chinese Windows environment is cp936 (GBK). ②fileencodings (FENC): Vim will open the file according to the Fileencodings option to identify the file encoding, Fileencodings can set multiple encodings at the same time, Vim will be based on the order of settings to guess the encoding of the open file. ③fileencoding (Fencs): Vim is saved when the new file is saved according to the fileencoding settings encoding. If you open an existing file, Vim saves it based on the encoding recognized when you open the file, unless you reset fileencoding on save. ④termencodings (TENC): When using VIM in a terminal environment, the encoding used by the Vim terminal is told by Termencoding Word.

Encoding conversion in VIM

Vim internally uses the Iconv library for encoding conversion, and if the encoding set by these options is inconsistent, VIM may convert the encoding. When an existing file is opened, it is converted from the file encoding to the encoding set by the encoding;
When you save a file, the encoding that is set from encoding is converted to the fileencoding corresponding encoding. You will often see VIM tips[converted], which is an indication that vim internally makes a coded conversion.
Using VIM in the terminal environment will convert the encoding from the Termencoding setting to the encoding of the encoding setting.
PS: You can use |:help encoding-values| to list all the encodings supported by VIM.

4. How to change the encoding of existing files:

① such as converting the GBK format to utf-8 Format: Method: Open the file first, using the command:Setfileencoding=utf-8② using the iconv command: [[email protected]~]# Iconv--List[[email protected]~]# ICONV-F originally encoded-t new encoded filename [-o newfile] options and Parameters:--list: List of language data supported by Iconv-F: from, that is, the meaning of the source, followed by the original encoding format;-t:to, that is, later the new code if what format;-O File: If you want to keep the original file, then use-o New file name, you can create a new encoded file. Example one: to/tmp/vitest/Vi.big5 turn it into UTF8 code! [[Email protected]~]# cd/tmp/Vitest[[email protected] vitest]# iconv-F big5-t UTF8 Vi.big5-o vi.utf8[[email protected] vitest]# file VI*Vi.big5:ISO-8859text, with CRLF line Terminatorsvi.utf8:UTF-8Unicode text, with CRLF line terminatorsPS: Quote from "Bird's-brother's private cuisine" ~~~

5. References:

http://blog.chinaunix.net/uid-26808060-id-4338345.htmlhttp://www.cnblogs.com/ Xkfz007/archive/2011/11/17/2252019.html

Win using Telnet to Ubuntu under Vim display Chinese as garbled solution ~

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.