Monday, October 25, 2010

Re: Statusline with %b, %B and %O matching ga

On Mon, 25 Oct 2010, Christian Brabandt wrote:

> Hi Benjamin!
>
> On Mo, 25 Okt 2010, Benjamin R. Haskell wrote:
>
>> %{printf("Oct=%03o",char2nr(strpart(getline("."),col(".")-1,1)))}
>>
>> (tested, but the behavior on empty lines could be improved)
>
> If I am not mistaken, this fails on multibyte chars.
>

As usual, you're not. :-)

Improved to handle multibyte chars:

%{printf("Oct=%03o",char2nr(get(split(strpart(getline("."),col(".")-1),"\\zs"),0,"")))}

(The 'get()' might be a bit inelegant, but it prevents errors on empty
lines.)

--
Best,
Ben

--
You received this message from the "vim_use" 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

No comments:

Post a Comment