Re: how to make vim support GB18030
- On 02/03/09 16:06, bill lam wrote:
> On Mon, 02 Mar 2009, Zhu OUYANG wrote:GB18030 is the latest official encoding standard of the People's
>> I need vim to correctly show the GB18030 characters, but seems my vim not
>> supporting it. I used command "*help encoding-values*", but there is no
>> GB18030 in the list.
>> So my question is:
>> 1. Is there any easy way to make vim support GB18030?
> No experience in using GB18030, Is it the same as cp936? I you don't
> use any 4 byte codes, I guess it should be same as cp936.
Republic of China; it extends former mainland-Chinese encodings such as
GB2312, GBK, etc. so as to allow representing any Unicode codepoint, but
(unlike UTF-8) in a manner which is favourable to Chinese. According to
the appropriate Wikipedia articles, any new computers offered for sale
in the PRC have to support GB18030. If you use only GBK codes it is
compatible with GBK, but what's the advantage then? Where GB18030 comes
into play is (for instance) for text which includes "rare hanzi" not
representable in GBK, such as the Unicode codepoints above U+20000.
>Yes, as has been said, one possibility (which I recommend) is to:
>> 2. If answer is "no", then, is there any simple tools (not libs) could
>> easily transform it into utf-8?
> You can use a command line program 'iconv' to convert between
> different encodings.
- make sure your Vim is compiled with +multi_byte (or +multi_byte_ime or
+multi_byte_ime/dyn) and +iconv (or +iconv/dyn).
- if +iconv/dyn, make sure you have the iconv or libiconv shared library
in the $PATH.
- You can check if iconv is actually available by means of ":echo
has('iconv')" (without the double quotes). The answer must be nonzero
for it to work.
- Start Vim with 'encoding' set to utf-8 (possibly in the vimrc, as
- When you want to edit a GB18030 file, use ++enc=GB18030 as in ":e
Now here's the code snippet to set UTF-8 in your vimrc (its length is
largely due to the heavy commenting I used):
" can only use multibyte encoding if
" the required feature is compiled-in
" if already Unicode, no need to change it
if &enc !~? '^u'
" don't make the keyboard non-functional
" (especially on non-Windows)
if &tenc == ""
let &tenc = &enc
" now we may switch
" file-encoding recognition heuristics
" tried from left to right
" ucs-bom should be first
" anything after the first 8-bit encoding
" will never be used (no 'fail' signal)
" the following is a typical value;
" others can also be used depending on
" what kind of files we edit most often
" defaults for newly-created files
" 'bomb' has no effect for non-Unicode 'fileencoding's
" the following will apply it when using
" ++enc=utf-8, ++enc=utf-16le, or similar
" 'fenc' default can be overridden by ++enc
" vary at will
setglobal bomb fenc=latin1
" if not compiled-in, we can't use it: warn the user
" Note: no warning, but no multi-byte either,
" if compiled without +eval
" (if-else-endif is a nestable comment in that case)
echomsg 'Warning: no multibyte support
"Love is an ideal thing, marriage a real thing; a confusion of the real
the ideal never goes unpunished."
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php