unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: <tomas@tuxteam.de>
To: help-gnu-emacs@gnu.org
Subject: Re: The correspondence of the command-name and its key-sequence.
Date: Mon, 11 Jan 2021 10:51:55 +0100	[thread overview]
Message-ID: <20210111095155.GB23284@tuxteam.de> (raw)
In-Reply-To: <87im83q3z5.fsf@omarpolo.com>

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

On Mon, Jan 11, 2021 at 09:20:46AM +0100, Omar Polo wrote:
> 
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
> 
> > On Sat, Jan 9, 2021 at 6:00 PM Omar Polo <op@omarpolo.com> wrote:
> > [...]
> >
> > Why the \ has two forms in the ascii document as shown below:
> >
> > $ man ascii | grep -F '\\'
> >        034   28    1C    FS  (file separator)        134   92    5C    \  '\\'
> >
> > As you can see, the document gives two forms of it:
> >
> >  \  '\\'
> 
> I guess, but it's only a guess, that's because \ is used for escaping
> chars.

The man page quoted above confirms your guess. Let me quote some relevant
lines (elisions marked with [...]):

man ASCII:

 | DESCRIPTION
 |   ASCII  is  the  American  Standard  Code for Information Interchange.
 |   It is a 7-bit code.  Many 8-bit codes (e.g., ISO 8859-1) contain ASCII
 |   as their lower half.  The international counterpart of
 |   ASCII is known as ISO 646-IRV.
 | 
 |   The following table contains the 128 ASCII characters.
 | 
 |   C program '\X' escapes are noted.
 | 
 |   Oct   Dec   Hex   Char                        Oct   Dec   Hex   Char
 |   ────────────────────────────────────────────────────────────────────────
 |   000   0     00    NUL '\0' (null character)   100   64    40    @
 |   001   1     01    SOH (start of heading)      101   65    41    A
 |   002   2     02    STX (start of text)         102   66    42    B
 | [...]
 |   032   26    1A    SUB (substitute)            132   90    5A    Z
 |   033   27    1B    ESC (escape)                133   91    5B    [
 |   034   28    1C    FS  (file separator)        134   92    5C    \  '\\'
 |   035   29    1D    GS  (group separator)       135   93    5D    ]

The relevant bit is the phrase above "C program '\X' escapes are
noted". Background is that, for C character and string literal
notation, an "escape convention" is used: whenever you want to
write a non-printable character, you use a so-called "escape
character" followed by something else. For example, for a newline
character, you say '\n', the escape being the '\'.

Now what do you do when trying to represent the escape character
itself? You just double it, like so: '\\'.

For lots of background, history, and the different conventions
in use, the Wikipedia page [1] is, as often, a great resource.

Cheers

[1] https://en.wikipedia.org/wiki/Escape_character

 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2021-01-11  9:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-09  6:05 The correspondence of the command-name and its key-sequence Hongyi Zhao
2021-01-09  6:32 ` Drew Adams
2021-01-09  7:16   ` Hongyi Zhao
2021-01-09  8:23     ` Omar Polo
2021-01-09  9:33       ` Hongyi Zhao
2021-01-09 10:00         ` Omar Polo
2021-01-11  8:04           ` Hongyi Zhao
2021-01-11  8:20             ` Omar Polo
2021-01-11  9:51               ` tomas [this message]
2021-01-09 17:20         ` Francis Belliveau
2021-01-14 22:21           ` ASCII - Why...? -- as promised Francis Belliveau
2021-01-09 21:21     ` The correspondence of the command-name and its key-sequence Drew Adams
2021-01-09 17:39 ` Kévin Le Gouguec
2021-01-09 18:47   ` Eduardo Ochs
2021-01-09 22:29     ` Kévin Le Gouguec

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210111095155.GB23284@tuxteam.de \
    --to=tomas@tuxteam.de \
    --cc=help-gnu-emacs@gnu.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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).