zsh-users
 help / color / mirror / code / Atom feed
From: Erik Bernstein <erik@fscking.org>
To: "Jun T." <takimoto-j@kba.biglobe.ne.jp>
Cc: zsh-users@zsh.org
Subject: Re: Match length and multibyte characters
Date: Thu, 17 Sep 2015 17:14:01 +0200	[thread overview]
Message-ID: <CAC_auRefjfTyO76UN2XNnMhnQqVUZTDF-G=+0rKCw5s+PZf1xw@mail.gmail.com> (raw)
In-Reply-To: <FCD65B5C-D8F2-466B-AE3C-D34131252659@kba.biglobe.ne.jp>

>> % array=(a ä a)
>> % print ${${(O)array//(#m)*/${#MATCH}}[1]} ${${(ON)array%%*}[1]}
>> 1 2
>>
>> Can maybe someone shed some light on whether the second version is
>> supposed to work with multibyte characters and,
>
> The second version returns 2 because ä is a 2 byte character in UTF-8.
> This is a bug of the current zsh; all the flags N, B and E do not work
> well with multibyte characters in ${...#...}, ${...%...} etc.

Thanks for clearing that up. I was just unsure whether this is really
a bug or if there's another flag that I have to apply in order to make
it work with unicode characters, too.


> The patch below may fix the bug.

This is what I get after applying your patch:

/home/debian/zsh-5.0.7/obj/Src/../../Src/glob.c:2489: undefined
reference to `MB_METASTRLEN2END'
/home/debian/zsh-5.0.7/obj/Src/../../Src/glob.c:2495: undefined
reference to `MB_METASTRLEN2END'
/home/debian/zsh-5.0.7/obj/Src/../../Src/glob.c:2483: undefined
reference to `MB_METASTRLEN2END'

Might be due to my old version of 5.0.7, I didn't try 5.1.1. In any
case, I'd rather work around this bug until it gets fixed upstream
than patch each zsh on all of my machines individually.

> BTW, in your example, it is better to replace the flag (O) by (On)

True. I've used (On) during my tests but then forgot the crucial n in
my posting.

Best

erik


      parent reply	other threads:[~2015-09-17 15:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-10 11:35 Erik Bernstein
2015-09-11 18:02 ` Jun T.
2015-09-11 19:40   ` Jun T.
2015-09-17 15:14   ` Erik Bernstein [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='CAC_auRefjfTyO76UN2XNnMhnQqVUZTDF-G=+0rKCw5s+PZf1xw@mail.gmail.com' \
    --to=erik@fscking.org \
    --cc=takimoto-j@kba.biglobe.ne.jp \
    --cc=zsh-users@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).