On 06/01/09 12:31, anhnmncb wrote: > Hi, list, as title, if so, why can't many functions > still handle correctly with unicode? For example the func: > > getline('.')[col('.')-1] > > Can't return a charactor outside the range of ascii. >
because string[index] returns a byte value, not a character value: see ":help expr8". If the character at the cursor is > U+007F, you'll get the first byte (in the range 0xC0-0xFD, or in practice in the range 0xC0-0xF4) of its UTF-8 representation. The _character_ at the cursor is obtained as follows: let i0 = byteidx(getline('.'), virtcol('.') - 1) let i1 = byteidx(getline('.'), virtcol('.')) let character = strpart(getline('.'), i0, i1 - 10) Best regards, Tony. -- Q: How many hardware engineers does it take to change a lightbulb? A: None. We'll fix it in software. --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---