help / color / mirror / code / Atom feed
From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: "Jason C. Kwan" <jasonckwan@yahoo.com>,
	"zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: bug report : printf %.1s outputting more than 1 character
Date: Wed, 15 Mar 2023 16:50:43 +0100	[thread overview]
Message-ID: <CAN=4vMqPdmpcSM6nQLFt7a+Jxo_+idbYd7AGs7qyfzS5Jj3COg@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7ZsHMF_x=O3iE_dqtyaV7FpVK7Sgurf2=5=hbC=fSCLdw@mail.gmail.com>

On Wed, Mar 15, 2023 at 4:32 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Tue, Mar 14, 2023 at 9:56 PM Jason C. Kwan <jasonckwan@yahoo.com> 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.


  reply	other threads:[~2023-03-15 15:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1621619253.265114.1678847919086.ref@mail.yahoo.com>
2023-03-15  2:38 ` Jason C. Kwan
2023-03-15  3:46   ` Bart Schaefer
2023-03-15  4:56     ` Jason C. Kwan
2023-03-15 15:31       ` Bart Schaefer
2023-03-15 15:50         ` Roman Perepelitsa [this message]
2023-03-18 16:56         ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAN=4vMqPdmpcSM6nQLFt7a+Jxo_+idbYd7AGs7qyfzS5Jj3COg@mail.gmail.com' \
    --to=roman.perepelitsa@gmail.com \
    --cc=jasonckwan@yahoo.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).