On 19-Dec-2011 13:07, Дмитрий Франк wrote: > line2byte() does not care multi-byte characters. > > For example, if my buffer has file-encoding utf-8, and there's some > cyrillic characters in the buffer (each cyrillic charater takes 2 > bytes), then line2byte('.') returns wrong result (it doesn't care > about multi-byte characters)
As stated in the help, line2byte() is about byte indexes, not character counts, like many other Vim functions (stridx(), strlen(), etc.) You have to convert to a character count yourself: let cnt = strchars(str) " new in Vim 7.3 let cnt = strlen(substitute(str, '.', 'x', 'g')) This seems to be much faster for long strings: let cnt = len(split(str, '\zs')) -- regards, ingo -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php