From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: (LC_ALL=C; set -x 128 129; printf "%s\n" ${(#)@} | hexdump -C)
Date: Wed, 30 Aug 2023 12:45:54 -0700 [thread overview]
Message-ID: <CAH+w=7b58OFubjUOdYuqm0U3hYPKFbX-GSuj7R7H6T8jmtTG2Q@mail.gmail.com> (raw)
In-Reply-To: <20230830072753.hhveg7teosubwzq7@chazelas.org>
On Wed, Aug 30, 2023 at 12:28 AM Stephane Chazelas
<stephane@chazelas.org> wrote:
>
> $ zsh -c 'LC_ALL=C; set -x 128 129; printf "%s\n" ${(#)@} | hexdump -C'
> +zsh:1> printf '"%s\n"' ''
> +zsh:1> hexdump -C
> 00000000 22 0a 22 |"."|
> 00000003
This doesn't happen if you add +o multibyte:
+zsh:1> printf '%s\n' $'\M-\C-@' $'\M-\C-A'
+zsh:1> hexdump -C
00000000 80 0a 81 0a |....|
00000004
Doc for (#) says:
If the MULTIBYTE option is set and the number is greater than 127
(i.e. not an ASCII character) it is treated as a Unicode
character.
> Does not happen without LC_ALL=C or with just "set -x 128" or with values <
> 128, or with printf "%s\n" $'\200' $'\201'
So $'\200' isn't subject to unicode interpretation where ${(#):-128}
is. But this also doesn't happen with 2 separate arguments
${(#):-128} ${(#):-129}, only with ${(#)@}. So something about the
implementation of $@ is mucking up the unicode translation, possibly
by leaving it thinking it's in the middle of an incomplete byte
sequence? It's also different with double quotes around $@:
% zsh -fc 'LC_ALL=C; set -x 128 130; printf "%s\n" "${(#)@}" | hexdump -C'
+zsh:1> printf '"%s\n"' '"'
+zsh:1> hexdump -C
00000000 22 22 0a 22 |""."|
00000004
next prev parent reply other threads:[~2023-08-30 19:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-30 7:27 Stephane Chazelas
2023-08-30 19:45 ` Bart Schaefer [this message]
2023-08-31 17:38 ` Jun. T
2023-09-07 14:26 ` Jun. T
2023-09-07 16:33 ` Peter Stephenson
2023-09-08 16:30 ` Jun. T
2023-09-11 8:57 ` Peter Stephenson
2023-09-11 12:11 ` Jun. T
2023-09-13 9:59 ` Jun T
2023-09-21 9:26 ` 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='CAH+w=7b58OFubjUOdYuqm0U3hYPKFbX-GSuj7R7H6T8jmtTG2Q@mail.gmail.com' \
--to=schaefer@brasslantern.com \
--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).