Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: printf %s in UTF-8 is not POSIX-compliant



On 2008-03-04 09:40:07 +0000, Peter Stephenson wrote:
> That seems to me useless.

But that what's POSIX requires (and this hasn't changed in the latest
draft). Also, there may be reasons (e.g. file formats with limited
field sizes). So, zsh should follow the specification, at least when
it emulates sh, since the user may write scripts based on it.

> I can understand in C that a string is a low-level entity consisting
> of a set of bytes, but I don't see why a shell should force the user
> to count the size of a multibyte character in the particular locale.

Well, there could be an extension to give the sizes in characters
instead of bytes.

> You can fix it by unsetting the MULTIBYTE option.
> 
> printf() { emulate -L zsh; unsetopt multibyte; builtin printf "$@" }

There's a missing semi-colon:

printf() { emulate -L zsh; unsetopt multibyte; builtin printf "$@"; }

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)



Messages sorted by: Reverse Date, Date, Thread, Author