From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: zsh-workers@zsh.org
Subject: Question about mb_metastrlen
Date: Tue, 27 Oct 2015 09:31:02 +0100 [thread overview]
Message-ID: <CAKc7PVBM070eO+zb8GEUjiuWvksBEYVQRmcQRr0CHYp_xifVAg@mail.gmail.com> (raw)
Hello,
the function counts bytes in last incomplete wide character:
ret = mbrtowc(&wc, &inchar, 1, &mb_shiftstate);
if (ret == MB_INCOMPLETE) {
num_in_char++;
} else {
When returning, it makes use of the count:
/* If incomplete, treat remainder as trailing single bytes */
return num + num_in_char;
Strings are stored in wchar_t arrays. The incomplete character will
occupy single index, correct? So maybe the return should be:
return num + ( num_in_char > 0 ? 1 : 0 );
?
Best regards,
Sebastian Gniazdowski
next reply other threads:[~2015-10-27 8:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-27 8:31 Sebastian Gniazdowski [this message]
2015-10-27 9:10 ` Peter Stephenson
2015-10-27 10:34 ` Sebastian Gniazdowski
2015-10-27 10:50 ` 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:
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=CAKc7PVBM070eO+zb8GEUjiuWvksBEYVQRmcQRr0CHYp_xifVAg@mail.gmail.com \
--to=sgniazdowski@gmail.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).