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

Re: printf %<n>s in UTF-8 is not always POSIX-compliant



On Feb 15,  3:15am, Vincent Lefevre wrote:
}
} In UTF-8 locales:
} 
} xvii% printf ".%2s.\n" é
} .é.

Am I understanding correctly that the intent here is that é is a two-
byte character so %2s should print the two literal bytes, rather than
print the single logical character in a field two logical characters
wide?

The reason it's different for "emulate sh" is that sh emulation turns
off all support for multibyte characters (unsetopt multibyte).  If you
were to do
	emulate sh -c 'setopt multibyte; printf ".%2s.\n" é'
then I believe you'd see the same behavior as with "emulate ksh".

As to whether it's correct ... I think I'd prefer the logical rather
than literal interpretation, but it'll be difficult [or a hack that
requires looking at the global emulation state, so it won't be possible
to reproduce it with plain setopts] to turn off multibyte processing in
printf for ksh emulation but not native zsh.



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