воскресенье, 11 ноября 2012 г., 15:40:32 UTC+4 пользователь lith написал:
> Am Sonntag, 11. November 2012 10:03:49 UTC+1 schrieb ZyX:
> > > Is this intended? Is there an (easy) way to make printf() respect 
> > > multi-byte encodings?
> > It is clearly stated in documentation that printf() operates with bytes.
> 
> My question rather was am I missing something since I personally find this 
> behaviour rather useless in the context of a text editor.
> 
> A formatted string usually is something that should eventually be displayed 
> in a vim buffer. When I want to get a string padded with whitespace, I'm 
> almost always rather interested in its display width than in its size in 
> bytes -- and I can hardly imagine a use case where it would be otherwise.
>
> I can work around this problem by adjusting the width dependent on the 
> difference between len(s) and strwidth(s) but I personally find this 
> unnecessarily complicated.

I don't say this is very useful, I am as well constantly finding myself writing 
code that uses strdisplaywidth for this job (with an emulation function for 
older vims) in case I think there may be any unicode characters (sometimes I 
know there will be no, like when displaying progress bar with "[==> ]"). It is 
just answer on the first question: yes, this was intended. It is how POSIX 
printf works, it is expected by any C programmer and it is here for backwards 
compatibility and historical reasons.

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

Raspunde prin e-mail lui