zsh-workers
 help / color / mirror / code / Atom feed
* [bug] locale ctype not always honoured properly in pcre matching
@ 2022-09-20 13:54 Stephane Chazelas
  2022-09-20 23:08 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Stephane Chazelas @ 2022-09-20 13:54 UTC (permalink / raw)
  To: Zsh hackers list

$ 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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-09-21 17:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-20 13:54 [bug] locale ctype not always honoured properly in pcre matching Stephane Chazelas
2022-09-20 23:08 ` Bart Schaefer
2022-09-21 17:41   ` Jun. T

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