Cyril Slobin wrote:
On 3/7/07, A.J.Mechelynck <[EMAIL PROTECTED]> wrote:

As long as 'encoding' is set to UTF-8, there is no easy way to get the cp936
value of a given character in the buffer.

I don't know if there is something specific with cp936, but for
encodings I use daily
(cp866, cp1251, koi8-r) the following works:

set statusline= <skip> %{HexDec()} <skip>

<skip>

function! HexDec()
 let char = matchstr(getline("."), ".", col(".") - 1)
 if g:EXTERNAL
   let char = iconv(char, &encoding, &fileencoding)
   let format = "0x%02X <%d>"
 else
   let format = "0x%02X (%d)"
 endif
 let char = char2nr(char)
 return printf(format, char, char)
endfunction

<skip>

nmap <silent> <F4> :let EXTERNAL = !EXTERNAL<CR>
imap <F6> <C-O><F4>

Code of a character under cursor is always displayed in statusline (in
both hex and dec),
and I can switch between `encoding` and `fileencoding`.


IIUC, the above is for 'encoding' and 'fileencoding' being both 8-bit encodings. cp936 is the Microsoft encoding for mainland China: some characters (such as ASCII) are 8 bits, others are 16 bits; and UTF-8 (the 'encoding' Zhaojun uses) can use anywhere between 1 and 4 bytes to represent the "assigned" codepoints. For instance, the highest Unicode codepoint currently regarded as "valid" by the Unicode Consortium, U+10FFFD, is represented in UTF-8 as F4 8F BF BD.

Best regadrs,
Tony.
--
Don't take life so serious, son, it ain't nohow permanent.
                -- Walt Kelly

Reply via email to