Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: The q parameter expansion flag does not support Unicode



On 2026-07-12 13:59:46 +0100, Stephane Chazelas wrote:
> On 2026-07-12 11:04, Vincent Lefevre wrote:
> [...]
> >   var=$(printf "A\bB\u2060C")
> >   printf "%s\n" ${(q)var}
> >   printf "%s\n" $var:q
> > 
> > the \b is quoted as $'\b', but the U+2060 WORD JOINER character
> > is not quoted though it is not printable. I would have expected
> > it to be quoted as $'\u2060'.
> 
> [[ $'\u2060' = [[:print:]] ]] returns true for me in the en_GB.UTF-8 locale
> of a Debian system (with glibc 2.42).

Indeed, but there is something strange with zsh, because if I type

  printf "%s\n" $var

then [Tab] just after "$var", I get

  printf "%s\n" A$'\b'B<2060>C

with <2060> in reverse video.

Moreover, in xterm, in the output of

  printf "%s\n" $var:q

when I copy "BC", the U+2060 character is dropped, but this seems
to be a bug in xterm as both rxvt and GNOME Terminal are fine.

In any case, there is a visibility issue.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)




Messages sorted by: Reverse Date, Date, Thread, Author