Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: sh emulation POSIX non-conformances (printf %10s and bytes vs character)
On 2021-04-24 19:20:53 -0700, Bart Schaefer wrote:
> On Sat, Apr 24, 2021 at 4:18 PM Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
> >
> > On 2021-04-24 15:28:21 -0700, Bart Schaefer wrote:
> > > On Sat, Apr 24, 2021 at 2:53 PM Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
> > > >
> > > > And perl has the same issue as zsh with double-width characters.
> > >
> > > This implies to me that it's not actually a zsh problem.
> >
> > Why not?
>
> Because multiple programs exhibiting identical incorrect behavior
> points to a problem in the C library or a system call.
Perl is not the same language as zsh. For instance:
$ perl -le 'for (@ARGV) {printf "|%10s|\n", $_}' Stephane Stéphane
| Stephane|
| Stéphane|
So, now, you have a different behavior with Perl.
I assume that the intent in Perl was not column formatting, but to be
similar to C. So I suppose that the Perl printf behaves like printf(3)
for 8-bit strings, and like wprintf(3) for Unicode strings. Note that
this is independent of the locales, i.e. the Perl printf is not
sensitive to the locales for %s, this is more like a datatype-based
behavior.
--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author