You need to have iconv for Win32. Get it here:
http://sourceforge.net/project/showfiles.php?group_id=25167&package_id=51458
Put intl.dll as libintl..dll where gvim.exe is. Also put iconv.dll
there or somewhere in the path.
Then you can use the UTF encoding in Vim (have set encoding=utf-8 in
_vimrc), and use such a command to open a GB18030 file:
:e ++enc=gb18030 SomeFile
If need be, you can also use the iconv command line to convert the encoding.
Last but not least, even if Vim understands the characters correctly,
they may not necessarily display correctly inside the GUI. I have not
tested about it, though.
Best regards,
Yongwei
--
Wu Yongwei
URL: http://wyw.dcweb.cn/
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.
> 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.
--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
唐詩103 李白 聽蜀僧濬彈琴
蜀僧抱綠綺 西下峨眉峰 為我一揮手 如聽萬壑松
客心洗流水 餘響入霜鐘 不覺碧山暮 秋雲暗幾重
GB18030 is the latest official encoding standard of the People's
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.
>
>> 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.
>
Yes, as has been said, one possibility (which I recommend) is to:
- 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
shown below)
- When you want to edit a GB18030 file, use ++enc=GB18030 as in ":e
++enc=GB18030 filename".
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 has('multi_byte')
" 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
endif
" now we may switch
set enc=utf-8
endif
" 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
set fencs=ucs-bom,utf-8,default,latin1
" 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
else
" 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
endif
Best regards,
Tony.
--
"Love is an ideal thing, marriage a real thing; a confusion of the real
with
the ideal never goes unpunished."
-- Goethe