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`.

--
Cyril Slobin <[EMAIL PROTECTED]> `When I use a word,' Humpty Dumpty said,
<http://45.free.net/~slobin> `it means just what I choose it to mean'

Reply via email to