How does \e represent the escape key? Where do you find that?
If I look at the ascii table I see that the escape key can be represented as: 27 (decimal), 1B (hexadecimal), 033 (octal). But I am not sure how to test whether the value returned from ReadKey is one of those.
| [reply] |
Where do you find that?
kcott is right that I simply looked at the code's output, but it's also documented in Quote and Quote like Operators.
If I look at the ascii table I see that the escape key can be represented as: 27 (decimal), 1B (hexadecimal), 033 (octal).
Those work too: the string "\e" is the same as "\x1B" and "\033" - you can try this out yourself with eq.
| [reply] [d/l] [select] |
| [reply] |
Press a key
$VAR1 = "\e";
Escape pressed
Had you pressed the enter key:
Press a key
$VAR1 = "\n";
I suggest you also read ++haj's post for additional information
and alternative methods to use.
| [reply] [d/l] [select] |
Yes, my mistake. I see that now.
| [reply] |
If I look at the ascii table
then you only see a part of the non-printable characters available on modern computer systems. Unicode has more control characters, emoji skin tone modifiers, right-to-left mark and a host of other stuff that is unprintable on it's own.
As an additional bonus, the same character on screen can sometimes be encoded in Unicode in multiple ways, see Unicode equivalence.
Unfortunately, input processing has gotten a tad more complex since the world gave up on ye olde ASCII table. On the bright side, these days more than the 20% of world population of the old ASCII days can now type their name into a computer with a reasonable expectation that it will be processed correctly.
perl -e 'use Crypt::Digest::SHA256 qw[sha256_hex]; print substr(sha256_hex("the Answer To Life, The Universe And Everything"), 6, 2), "\n";'
| [reply] [d/l] |
I generally agree with everything you've written there; however, as a minor nitpick,
those skin tone modifiers can be printed in isolation.
I'm not sure how this will render on different browsers, but on my terminal:
$ perl -C -E '
say for
"\N{U+1F3FB}",
"\N{U+1F3FC}",
"\N{U+1F3FD}",
"\N{U+1F3FE}",
"\N{U+1F3FF}"
'
🏻
🏼
🏽
🏾
🏿
And, in a preview, that looks fine on my Firefox v100.0.2 — YMMV.
| [reply] |