From: Erik Bernstein <erik@fscking.org>
To: zsh-users@zsh.org
Subject: Match length and multibyte characters
Date: Thu, 10 Sep 2015 13:35:51 +0200 [thread overview]
Message-ID: <CAC_auRfyDuJ-JoeSE9zfnhO=fy4bjOrK0rT8=97O_XeE4SKxNA@mail.gmail.com> (raw)
Hello everybody,
while playing around with zsh expansions, I've stumbled across this
small annoyance that I think might be worth to ask the list about.
Let's suppose I have an array and I want to know the length of the
longest string contained. After going through zshexpn(1), the first
thing I came up with was:
% array=(a bbb cc)
% print ${${(O)array//(#m)*/${#MATCH}}[1]}
3
which is perfectly fine and seems to do the job. Later I found that
the same thing can be accomplished by this.
% print ${${(ON)array%%*}[1]}
3
However, the second version seems to break on multibyte characters
while the first one works just fine:
% 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, if, what has to be
done to make it count multibyte chars only once just like the first
version does?
regards
erik
next reply other threads:[~2015-09-10 11:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-10 11:35 Erik Bernstein [this message]
2015-09-11 18:02 ` Jun T.
2015-09-11 19:40 ` Jun T.
2015-09-17 15:14 ` Erik Bernstein
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_auRfyDuJ-JoeSE9zfnhO=fy4bjOrK0rT8=97O_XeE4SKxNA@mail.gmail.com' \
--to=erik@fscking.org \
--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).