zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-workers@zsh.org
Subject: Re: Question about mb_metastrlen
Date: Tue, 27 Oct 2015 10:50:21 +0000	[thread overview]
Message-ID: <20151027105021.20c5e67c@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <CAKc7PVB3yVAvs+n_4YcT-UxbKs0HcCOdU-xCxbF7Rx7spx1Q2Q@mail.gmail.com>

On Tue, 27 Oct 2015 11:34:35 +0100
Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:

> On 27 October 2015 at 10:10, Peter Stephenson <p.stephenson@samsung.com> wrote:
> > On Tue, 27 Oct 2015 09:31:02 +0100
> > The function you're talking about is for a string length, not a
> > character length.  num_in_char counts the number of trailing bytes that
> > didn't form a wide character.  Each will be treated as a single byte.
> > So each counts 1 for the length of the string.
> 
> There is the condition:
>             if (ret == MB_INVALID) {
> 
> Isn't it that if there are many trailing bytes that do not form a
> character, they will be catched into MB_INVALID, and only last
> "character" can stay as not yet complete?

Only the last multibyte character can consist of multiple individual
bytes that look like part of an incomplete character rather than simply
as invalid, that's correct.  Hence the note at the end of the function
about use of num_in_char, and hence we reset num_in_char to 0 any time
we get a full multibyte character or mark a byte as invalid rather than
incomplete.

pws


      reply	other threads:[~2015-10-27 10:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-27  8:31 Sebastian Gniazdowski
2015-10-27  9:10 ` Peter Stephenson
2015-10-27 10:34   ` Sebastian Gniazdowski
2015-10-27 10:50     ` Peter Stephenson [this message]

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=20151027105021.20c5e67c@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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

	https://git.vuxu.org/mirror/zsh/

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).