From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 2C85C25C51 for ; Sun, 25 Feb 2024 10:08:12 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1708852092; b=D5nl1UWrAT0V+1GlWFvUxIJDktcigc3WMNF9UjeA+frYbO59n5XcskazmsL2j7coOvGi74J+w9 AWfibmDAyK33tdWSCbmWUeBBNwUU4J1idPF7LNrwqSGcSQ9pU+9qgnJY7p3FH1MHTSotGCWa24 sMq6mxX59bjaQ3Qnc4zxoS+AHwEKC1tjGJa44BSPLxL7KHAcSP59pKgzx7Jgl3jFGVe92XSxcU xKTu5+qUHdUgmuoDqZ3qvfZyVHL1h9z6fBQ097j657ICVlMx+6BAU93v3SQ8w6m2jRlYIXqGag d54gtmjMuTpDjZcpQi038ZKmOhbGKrCMx5jttr0u0VAA6w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay8-d.mail.gandi.net) smtp.remote-ip=217.70.183.201; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1708852092; bh=T+nYqHiXn94jKifmGAvdSjdJhX8dqOn8SNsBlIbCaA8=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:MIME-Version:Message-ID:Subject:To:From:Date: DKIM-Signature; b=LZHy/ftLzJVyhfmOWg+1JRBCyBg1io/Z4WNmyy8cmbTaJF/PlMn119phvZu9CL9pHPDsOrKyLh px7Io+nEdZnbzn399/1R/ffdBsZ6+5fWBoZc/6eseUD+kSZ6pfRSnT0rH5RCFddvmTzK5JnbtZ JhbGPSapA2+e75jzx+tp9+3hzkiyEoztaLNw9O3WKZI3yVLOXc+vySCMIzmbqP4/NeZ9rKj3gS ebBg6XG2KrzakQrbfLyUUD7Q6V2nXUqEEdwGOekaL5Q+rlK9FXFtm+8wQ+aR4Dt4vKJNpr/I8+ YDzYpVkmTN0xN3/V6F2AVbiJ6yYvCi/68dH9YooUEHs3RA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:MIME-Version:Message-ID: Subject:To:From:Date:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=tDgrU+XoCp+7xb3mMSuYZSIxXKGCiQAlRHP0GYi9FrE=; b=U/X/54ypRvTclqWCUp7QJhpcV/ REkNC2mOjPm9LhLo5Q0m+79gkFBY3z6q4+706ydmekG8ynK0LsOpbKm1D5HHErNHDSeYKb1hudxib I8C3wSEE8f8cj+TQ8Ft10v1NkaMMRF71fzSpUtLhcR6x8TDexqzEhjb7FrT5wgoyTxchOYskoNJ8v kPai2amBcnIJIup7eY3FiR90iaTPiesZhBGPAAAk+5p5Srjto9HadxFq6qHtGW4tHprBBTWHaPfOo 40pEC3KsMkowk8CM0dQrO+32zBfipvoQ6N95XRsU8rie5njsmCgPn9vJT/qSLyPiPVXL9USKgUG84 3oeAZtHQ==; Received: by zero.zsh.org with local id 1reAUW-000ESc-9o; Sun, 25 Feb 2024 09:08:12 +0000 Authentication-Results: zsh.org; iprev=pass (relay8-d.mail.gandi.net) smtp.remote-ip=217.70.183.201; dmarc=none header.from=chazelas.org; arc=none Received: from relay8-d.mail.gandi.net ([217.70.183.201]:60143) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1reAUH-000E9F-LA; Sun, 25 Feb 2024 09:07:58 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 186F31BF204 for ; Sun, 25 Feb 2024 09:07:53 +0000 (UTC) Date: Sun, 25 Feb 2024 09:07:51 +0000 From: Stephane Chazelas To: Zsh hackers list Subject: \M-^C vs \203 vs \x83 as visual representations of bytes Message-ID: <20240225090751.yqb23ewm4pgocg7e@chazelas.org> Mail-Followup-To: Zsh hackers list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-GND-Sasl: stephane@chazelas.org X-Seq: 52604 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: 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