Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: bug report : printf %.1s outputting more than 1 character
- X-seq: zsh-workers 51580
- From: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: "Jason C. Kwan" <jasonckwan@xxxxxxxxx>, "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: Re: bug report : printf %.1s outputting more than 1 character
- Date: Wed, 15 Mar 2023 16:50:43 +0100
- Archived-at: <https://zsh.org/workers/51580>
- In-reply-to: <CAH+w=7ZsHMF_x=O3iE_dqtyaV7FpVK7Sgurf2=5=hbC=fSCLdw@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <1621619253.265114.1678847919086.ref@mail.yahoo.com> <1621619253.265114.1678847919086@mail.yahoo.com> <CAH+w=7bkqfUYbQ2DvZ7RPDZpSgZVxMZcT8orAiANZhWMY7fxHg@mail.gmail.com> <478761809.298180.1678856216911@mail.yahoo.com> <CAH+w=7ZsHMF_x=O3iE_dqtyaV7FpVK7Sgurf2=5=hbC=fSCLdw@mail.gmail.com>
On Wed, Mar 15, 2023 at 4:32 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> On Tue, Mar 14, 2023 at 9:56 PM Jason C. Kwan <jasonckwan@xxxxxxxxx> wrote:
> >
> > does the following ( below the "====" line ) behavior look even reasonable at all, regardless of your spec ? Because what the spec ends up doing is treating the rest of the input string as 1 byte and printing everything out, even though there are valid code points further down the input string.
>
> I'm not the resident expert on multibyte character sets, so I'm just
> reporting the situation and waiting for e.g. PWS to respond. However,
> as far as my understanding of the multibyte library goes, once you've
> "desynchronized" the input by encountering an invalid byte, you're not
> guaranteed that anything further that you see can be correctly
> interpreted as a code point. I agree that it's not ideal to just dump
> everything else "raw".
UTF-8 has a nice property that you can jump to an arbitrary byte
position in the stream and quickly find the start of the next
character. A byte is the start of a character if it has the most
significant bit equal to 0 or two most significant bits equal to 1.
This can also be used to recover after an invalid character.
Roman.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author