zsh-workers
 help / color / mirror / code / Atom feed
* \M-^C vs \203 vs \x83 as visual representations of bytes
@ 2024-02-25  9:07 Stephane Chazelas
  2024-02-25 17:26 ` Mark J. Reed
  2024-02-25 18:25 ` Stephane Chazelas
  0 siblings, 2 replies; 5+ messages in thread
From: Stephane Chazelas @ 2024-02-25  9:07 UTC (permalink / raw)
  To: Zsh hackers list

I guess \M-^C (or \M-\C-C) as the representation of 0x83 made
sense to people in the 80s/90s when they could actually type
Meta-Ctrl-C on their keyboard to input them.

Noaways, you can still enter ^C with Ctrl+C but bytes >= 0x80
are used for non-ASCII characters, and Alt-C usually sends ^[c
(0x1b 0x63) and Alt-Ctrl-C ^[^C (0x1b 0x3)

I find the \x83 representation more useful when giving visual
representations of bytes not forming part of a printable
characters (and \uffff / \U0010ffff for valid but non-printable
multi-byte characters). Octal used to be more popular than hex,
but I think nowadays it's the reverse, though I still find \203
more useful than \M-^C if not \x83.

What do people think?

Would it make sense to change some of the output intended for
user consumption such as:

$ a=$'\x83'
$ typeset a
a=$'\M-\C-C'
$ print -r ${(q+)a}
$'\M-\C-C'
$ (set -x; : $a)
+/bin/zsh:29> : $'\M-\C-C'


$ let $a
zsh: bad math expression: illegal character: \M-C
$ let 1+$a
zsh: bad math expression: operand expected at `\M-^C'

(another M-C vs M-^C bug above by the way).

Comparison with some other tools/shells:

$ echo $a | cat -v
M-^C
$ echo $a | sed -n l
\203$
$ bash -xc 'printf "%q\n" "$a"'
+ printf '%q\n' $'\203'
$'\203'
$ ksh -xc 'printf "%q\n" "$a"'
+ printf '%q\n' $'\x83'
$'\x83'

-- 
Stephane


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

end of thread, other threads:[~2024-02-25 20:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-25  9:07 \M-^C vs \203 vs \x83 as visual representations of bytes Stephane Chazelas
2024-02-25 17:26 ` Mark J. Reed
2024-02-25 18:50   ` Stephane Chazelas
2024-02-25 20:54   ` Bart Schaefer
2024-02-25 18:25 ` Stephane Chazelas

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