[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why does "\024" mean `C-t'? (in bindkey example in man page)

From: Axel Beckert
Subject: Re: Why does "\024" mean `C-t'? (in bindkey example in man page)
Date: Sat, 13 Aug 2016 18:09:28 +0200
User-agent: Mutt/1.5.21 (2010-09-15)


On Sat, Aug 13, 2016 at 05:41:41AM -0700, Aleksey Tsalolikhin wrote:
> The GNU screen man page states:
>     bindkey "\024" mapdefault
>      This keybinding makes `C-t' an escape character for keybindings.
> My 'ascii' man page shows that octal 024 is Device Control 4:
>        Oct   Dec   Hex   Char
>        024   20    14    DC4 (device control 4)
> And that "T" is octal 124:
>        Oct   Dec   Hex   Char
>        124   84    54     T
> I tried binding something to \024 and when I press Control-T I get that
> something.
> Why is \024 control-T rather than \124, please?

The ASCII characters from 1 to 26 (decimal) are so called
non-printable or control characters. They can be typed by pressing
Ctrl plus the according character. Since T is the 20th character in
the alphabet, Ctrl-T gives the ASCII control character number 20
(which is octal 24).

And actually the "real" characters start at ASCII character number 65
("A") which is octal 101, i.e. the position of a letter in the
alphabet is:

* also the number of its control character 
* the ASCII value of its capital letter if you add octal 100

This perl one-liner may explain it better, it outputs the hex, octal
and decimal ASCII value of each character typed into a line:

→ perl -E 'while (my $l=<>){ chomp($l); say join(" ", map { my $c=ord($_); 
sprintf("x%02X=o%03o=d%i", $c,$c,$c) } split(//,$l)) }'
x41=o101=d65 x42=o102=d66 x43=o103=d67

(Ctrl-Z needs to be typed Ctrl-V Ctrl-Z in most shells to not suspend
the perl program. And Ctrl-V needs to be typed Ctrl-V Ctrl-V and
Ctrl-C also needs to be prepended by Ctrl-V to escape from it's normal
interrupt meaning.)


                Kind regards, Axel
/~\  Plain Text Ribbon Campaign                   | Axel Beckert
\ /  Say No to HTML in E-Mail and News            | address@hidden  (Mail)
 X   See | address@hidden (Mail+Jabber)
/ \  I love long mails: | (Web)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]