From: Stephane Chazelas <stephane@chazelas.org>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: [bug] locale ctype not always honoured properly in pcre matching
Date: Tue, 20 Sep 2022 14:54:04 +0100 [thread overview]
Message-ID: <20220920135404.64r5fnrlgmgxogye@chazelas.org> (raw)
$ locale charmap
UTF-8
$ set -o rematchpcre
$ LC_ALL=C [ $'\xc3\xa9' '=~' '^..\z' ] && echo yes
yes
OK, in C locale, those two bytes are considered as two characters.
$ [ $'\xc3\xa9' '=~' '^..\z' ] && echo yes
$
OK, in UTF-8, those two bytes form one é character
$ LC_ALL=C [ $'\xc3\xa9' '=~' '^..\z' ] && echo yes
$
Same command as above, but now it doesn't match (?!) and instead:
$ LC_ALL=C [ $'\xc3\xa9' '=~' '^.\z' ] && echo yes
yes
Behaves as if doing a match in UTF-8.
Same goes with:
$ PS1='$ ' zsh -f
$ set -o rematchpcre
$ (LC_ALL=C; [[ $'\xc3\xa9' =~ '^..\z' ]] && echo yes )
yes
$ [[ $'\xc3\xa9' =~ '^..\z' ]] && echo yes
$ (LC_ALL=C; [[ $'\xc3\xa9' =~ '^..\z' ]] && echo yes )
$
--
Stephane
next reply other threads:[~2022-09-20 13:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-20 13:54 Stephane Chazelas [this message]
2022-09-20 23:08 ` Bart Schaefer
2022-09-21 17:41 ` Jun. T
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=20220920135404.64r5fnrlgmgxogye@chazelas.org \
--to=stephane@chazelas.org \
--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).