Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: The q parameter expansion flag does not support Unicode
- X-seq: zsh-workers 54962
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: The q parameter expansion flag does not support Unicode
- Date: Sun, 12 Jul 2026 20:24:47 +0200
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=LEGuL/pWOFgWTOUaUYD7le+6Er9oN+bQkJ0GNIyYO/M=; fh=SbTlPuNNxBzTkRlwWtqw/TXBY0HvGvtE97RpPp3sJPM=; b=ZtL74RZdSO/Gnxw9uwuofsYpSGNNKW/IOwCHxyMmoQSpI2PT7nx682xaN2aIKPRvEn xQa8ZqoT5bUdyJANZcegzd40cYKPIq5YHrtU8gm6dYaAB438v52PJ5PL4UVrlaNNXU7k jct1qi2jsZI3c3zSlfCX0tIITNd99wcrOAT5CeeLPNYcHMkWZcNZSSuOMnmCmn4aMwBW bRdyUwo0O63tpGBvlVfCnRygdWNnPZ9WBV8pqIM2HBT2Rhut7kwpAfoqxKKoJ3x5kC9p vZhXFu/xpezDvcT496ASDDcat6wN6xgEGV649jUjwldyDsYvHth8TOsjgf8vEU9bfGZa RhkA==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1783880702; cv=none; d=google.com; s=arc-20260327; b=mO8mTXfjPwwvpvlOPcVFFiMvGq+Cb37oVMcU1ALhrJIqgysgN71L5XtD1SvpgLYK5l 2SdoOFSUfPyT8ANRD9QZPvZt/+O7mrNIX+R4/Jo5qu+stI2iPDImOwZH1fYhRZ+Z9B3o L5N6ZNIPv9/DPy8m/f8xBOqXJcK1UnnmkvPX44CRmvrO1aST7M5sU4x0skllDQp1P4lV xOXop1vKJyKIacC5n4cbjtjJ6yKYCnzmDjNQEaHtBrPeEQ3W+7ncm8+QombP1UO7t8Qn teI3hpElcRF7hXw4IRXDr2jMWThb47/brfo+eRmslsEj2TQoZX7aDvx/8oL49YYZE9tk IOsg==
- Archived-at: <https://zsh.org/workers/54962>
- In-reply-to: <20260712163506.GC719379@qaa.vinc17.org>
- List-id: <zsh-workers.zsh.org>
- References: <20260712100448.GB719379@qaa.vinc17.org> <7f28629705434ee7b98ed6cc83391707@chazelas.org> <20260712163506.GC719379@qaa.vinc17.org>
On Sun, Jul 12, 2026 at 6:53 PM Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
>
> 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.
This is how all zerowidth characters (and other special characters)
are shown on the commandline when the combiningchars option is not
enabled.
> 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.
The problem is that the character in question is a format character
(in the Cf class). These return 0 for wcwidth and 1 for iswprint, so
there's not much we can do in terms of posix library calls to
distinguish them. We could query a custom library like utf8proc, and
apparently glibc also has an extension that lets you use iswctype(x,
wctype("combining")) to determine if it's a Cf or other combining
character.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author