Hi Tony,
On 2/28/07, A.J.Mechelynck <[EMAIL PROTECTED]> wrote:
>> However, if gb18030 is used in the environment
>> that means that console output needs to be converted, thus
>> 'termencoding' also needs to be set.
>
> Not if encoding==gbk. According to the discussion, Edward would want
> to alias GB18030 to GBK in the environment, and in that case, encoding
> will be GBK by default, and all characters output will be in the range
> of GBK, so no conversion is needed. If encoding is (manually set to)
> utf-8 while the environment is GB18030, the hack Edward uses has no
> effect at all (which, I believe, is to make sure Vim will by default
> get an encoding 'CP936' instead of 'Latin1', so Chinese can be
> processed correctly), and one would need to manually set tenc to
> gb18030 anyhow.
If 'encoding' is manually set to UTF-8, this doesn't change how the
keyboard and, in Console Vim, the display process characters.
Yes, it is correct, but there are no surprises. If people set encoding
to UTF-8 in a GBK environment, they will have similar issues. I would
expect people that tweak .*encodings\? options know their ways.
Now it happens that the default for 'termencoding' is empty, meaning
"use 'encoding'".
Maybe true for Linux. On Windows 'tenc' will be affected by the
console code page.
This, in turn, means that if we set 'encoding' to UTF-8 manually (by
keyboard or in the vimrc) we need to preserve the locale encoding in
'termencoding' to avoid garbling of keyboard input (and, in console
Vim, of terminal output).
That will be a new feature proposal. I would suppose people changing
encoding should change termencoding themselves.
Here is (IIUC) an example of how to set 'encoding' to UTF-8
"prudently" at the start of the vimrc:
if has("multi_lang")
" preserve menu charset
let &langmenu = v:lang
if &langmenu !~ '\.'
let &langmenu .= '.' . &enc
endif
endif
if has("multi_byte")
if &enc !~? '^u' " if already Unicode, no change necessary
if &tenc == ""
let &tenc = &enc " preserve keyboard & xterm charset
endif
set enc=utf-8
endif
endif
runtime vimrc_example.vim " setup menus, syntax highlights, etc.
Generally speaking, I do not change the encoding in console Vim.
Unless the console is UTF-8 already, changing encoding to UTF-8 does
not gain much, since the console is not able to display the extra
characters not supported in the original encoding :-).
Best regards,
Yongwei
--
Wu Yongwei
URL: http://wyw.dcweb.cn/