zsh-workers
 help / color / mirror / code / Atom feed
From: "Mark J. Reed" <markjreed@gmail.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: \M-^C vs \203 vs \x83 as visual representations of bytes
Date: Sun, 25 Feb 2024 12:26:35 -0500	[thread overview]
Message-ID: <CAA=-s3yLhwkd7zy-2Fwky4DEOfoUD8UE9D14LqyY+yr3DPSyDA@mail.gmail.com> (raw)
In-Reply-To: <20240225090751.yqb23ewm4pgocg7e@chazelas.org>

[-- Attachment #1: Type: text/plain, Size: 1898 bytes --]

Wow; I had no idea Zsh printed out nonprintable characters that way. I
concur that it would make sense to change, modulo backward compatibility
considerations. Maybe a settable option?

 The M- "meta" syntax is something I associate with Emacs key-binding, and
have rarely seen in other contexts.

On Sun, Feb 25, 2024 at 4:08 AM Stephane Chazelas <stephane@chazelas.org>
wrote:

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

-- 
Mark J. Reed <markjreed@gmail.com>

[-- Attachment #2: Type: text/html, Size: 2654 bytes --]

  reply	other threads:[~2024-02-25 17:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-25  9:07 Stephane Chazelas
2024-02-25 17:26 ` Mark J. Reed [this message]
2024-02-25 18:50   ` Stephane Chazelas
2024-02-25 20:54   ` Bart Schaefer
2024-02-25 18:25 ` Stephane Chazelas

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='CAA=-s3yLhwkd7zy-2Fwky4DEOfoUD8UE9D14LqyY+yr3DPSyDA@mail.gmail.com' \
    --to=markjreed@gmail.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).