Subject: Re: German Win98, US Win95 keyboard --> no ;'` keys in Bash
From: "Gerrit P. Haase" <[email-masked]>
To: Corinna Vinschen <[email-masked]>
Date: Tue, 25 Sep 2001 17:01:35 +0200

> Corinna Vinschen schrieb am 2001-09-21 10:37:

>> but: gcc -o kc keycheck.c
>> doesn't work.
>> 
>> Gerrit
>
>We already have such a keyscan application in the Cygwin distro:
>
> cygcheck -k

Every visible key works for me on NT4, german version, us-keyboard, w/wo shift,
see output below script.

#!/usr/bin/perl

$USAGE = '
USAGE: ascii [options] [string]
SYNOPSIS: Print ASCII-CODE each char of input or the whole table.
AUTHOR: GPL(C) Mohsin Ahmed, http://www.cs.albany.edu/~mosh
OPTIONS string       Show  string in hex, oct, decimal.
        -table X Y   Print the table from X..Y, or 0..255.
        -oct         Octal table \000  \177.
        -hex         Hex   table \x00  \x7f.
        -xcolor      Show ESC sequences for color xterm.
WAS:      perl -e \'printf "%#x\n", ord(shift)\' "^]"
';

$TABLE_OCT = '
+---------------------------------------------------------------+
|000 nul|001 soh|002 stx|003 etx|004 eot|005 enq|006 ack|007 bel|
|010 bs |011 ht |012 nl |013 vt |014 np |015 cr |016 so |017 si |
|020 dle|021 dc1|022 dc2|023 dc3|024 dc4|025 nak|026 syn|027 etb|
|030 can|031 em |032 sub|033 esc|034 fs |035 gs |036 rs |037 us |
|040 sp |041  ! |042  " |043  # |044  $ |045  % |046  & |047  \' |
|050  ( |051  ) |052  * |053  + |054  , |055  - |056  . |057  / |
|060  0 |061  1 |062  2 |063  3 |064  4 |065  5 |066  6 |067  7 |
|070  8 |071  9 |072  : |073  ; |074  < |075  = |076  > |077  ? |
|100  @ |101  A |102  B |103  C |104  D |105  E |106  F |107  G |
|110  H |111  I |112  J |113  K |114  L |115  M |116  N |117  O |
|120  P |121  Q |122  R |123  S |124  T |125  U |126  V |127  W |
|130  X |131  Y |132  Z |133  [ |134  \ |135  ] |136  ^ |137  _ |
|140  ` |141  a |142  b |143  c |144  d |145  e |146  f |147  g |
|150  h |151  i |152  j |153  k |154  l |155  m |156  n |157  o |
|160  p |161  q |162  r |163  s |164  t |165  u |166  v |167  w |
|170  x |171  y |172  z |173  { |174  | |175  } |176  ~ |177 del|
+---------------------------------------------------------------+
';

$TABLE_HEX = '
+---------------------------------------------------------------+
| 00 nul| 01 soh| 02 stx| 03 etx| 04 eot| 05 enq| 06 ack| 07 bel|
| 08 bs | 09 ht | 0a nl | 0b vt | 0c np | 0d cr | 0e so | 0f si |
| 10 dle| 11 dc1| 12 dc2| 13 dc3| 14 dc4| 15 nak| 16 syn| 17 etb|
| 18 can| 19 em | 1a sub| 1b esc| 1c fs | 1d gs | 1e rs | 1f us |
| 20 sp | 21  ! | 22  " | 23  # | 24  $ | 25  % | 26  & | 27  \' |
| 28  ( | 29  ) | 2a  * | 2b  + | 2c  , | 2d  - | 2e  . | 2f  / |
| 30  0 | 31  1 | 32  2 | 33  3 | 34  4 | 35  5 | 36  6 | 37  7 |
| 38  8 | 39  9 | 3a  : | 3b  ; | 3c  < | 3d  = | 3e  > | 3f  ? |
| 40  @ | 41  A | 42  B | 43  C | 44  D | 45  E | 46  F | 47  G |
| 48  H | 49  I | 4a  J | 4b  K | 4c  L | 4d  M | 4e  N | 4f  O |
| 50  P | 51  Q | 52  R | 53  S | 54  T | 55  U | 56  V | 57  W |
| 58  X | 59  Y | 5a  Z | 5b  [ | 5c  \ | 5d  ] | 5e  ^ | 5f  _ |
| 60  ` | 61  a | 62  b | 63  c | 64  d | 65  e | 66  f | 67  g |
| 68  h | 69  i | 6a  j | 6b  k | 6c  l | 6d  m | 6e  n | 6f  o |
| 70  p | 71  q | 72  r | 73  s | 74  t | 75  u | 76  v | 77  w |
| 78  x | 79  y | 7a  z | 7b  { | 7c  | | 7d  } | 7e  ~ | 7f del|
+---------------------------------------------------------------+
';

$charname{    0 } = 'NUL';
$charname{    7 } = 'BEL';
$charname{    8 } = 'BS ';
$charname{    9 } = 'TAB';
$charname{   10 } = 'LF ';
$charname{   11 } = 'VT ';
$charname{   12 } = 'FF ';
$charname{   13 } = 'CR ';
$charname{   27 } = 'ESC';
$charname{   32 } = 'SPC';
$charname{  127 } = 'DEL';

while( $_ = $ARGV[0], /^-/ ){
    shift; m/^--$/ && last;
    if(     m/^-v/   ){ $verbose=1;
    }elsif( m/^-oct/ ){ print $TABLE_OCT; exit;
    }elsif( m/^-hex/ ){ print $TABLE_HEX; exit;
    }elsif( m/^-\?/  ){ print $USAGE;     exit;
    }elsif( m/^-xcolor/  ){
        # print ESC sequences for color xterm.
        for($i=0;$i<110;$i++){
            printf("\e[%03dm\\e[%3dm\e[0m\e[39m\e[49m,", $i, $i);
            print "\n" if $i % 8 == 0;
        }
        print "\nNormal Foreground: \\e[39m, Normal Background \\e[49m.\n";
        exit;
    }elsif( m/^-table/    ){ $opt  = 'table';
                             $from = shift || 0;
                             $to   = shift || 255;
        for $i ($from .. $to ){
            $c = $i;
            printf("%3d 0x%-3x \\0%-3o %3s  %c |  ",
                $i,     $i,     $i, $c, $i,
                $charname{ $i } || '-' );
            print "\n" unless $i % 2;
        }
        exit;
    }else{
        die "Invalid option '$_', see -? for help\n";
    }
}

my $string = shift
    or die $USAGE;

foreach $c (split(//,$string))
{
    my $i = ord($c);
    printf("ascii:%3s = dec: %3d, oct: %#o, hex: %#x;\n",
                    $c,        $i,       $i,       $i );
}

$ ascii.pl '`~1!2@3#4$5%6^7&8*9(0)-_=+qQwWeErRtTyYuUiIoOpP[{]}\|aAsSdDfFgGhHjJkKlL;:"zZxXcCvVbBnNmM,<.>/?'
ascii:  ` = dec:  96, oct: 0140, hex: 0x60;
ascii:  ~ = dec: 126, oct: 0176, hex: 0x7e;
ascii:  1 = dec:  49, oct: 061, hex: 0x31;
ascii:  ! = dec:  33, oct: 041, hex: 0x21;
ascii:  2 = dec:  50, oct: 062, hex: 0x32;
ascii:  @ = dec:  64, oct: 0100, hex: 0x40;
ascii:  3 = dec:  51, oct: 063, hex: 0x33;
ascii:  # = dec:  35, oct: 043, hex: 0x23;
ascii:  4 = dec:  52, oct: 064, hex: 0x34;
ascii:  $ = dec:  36, oct: 044, hex: 0x24;
ascii:  5 = dec:  53, oct: 065, hex: 0x35;
ascii:  % = dec:  37, oct: 045, hex: 0x25;
ascii:  6 = dec:  54, oct: 066, hex: 0x36;
ascii:  ^ = dec:  94, oct: 0136, hex: 0x5e;
ascii:  7 = dec:  55, oct: 067, hex: 0x37;
ascii:  & = dec:  38, oct: 046, hex: 0x26;
ascii:  8 = dec:  56, oct: 070, hex: 0x38;
ascii:  * = dec:  42, oct: 052, hex: 0x2a;
ascii:  9 = dec:  57, oct: 071, hex: 0x39;
ascii:  ( = dec:  40, oct: 050, hex: 0x28;
ascii:  0 = dec:  48, oct: 060, hex: 0x30;
ascii:  ) = dec:  41, oct: 051, hex: 0x29;
ascii:  - = dec:  45, oct: 055, hex: 0x2d;
ascii:  _ = dec:  95, oct: 0137, hex: 0x5f;
ascii:  = = dec:  61, oct: 075, hex: 0x3d;
ascii:  + = dec:  43, oct: 053, hex: 0x2b;
ascii:  q = dec: 113, oct: 0161, hex: 0x71;
ascii:  Q = dec:  81, oct: 0121, hex: 0x51;
ascii:  w = dec: 119, oct: 0167, hex: 0x77;
ascii:  W = dec:  87, oct: 0127, hex: 0x57;
ascii:  e = dec: 101, oct: 0145, hex: 0x65;
ascii:  E = dec:  69, oct: 0105, hex: 0x45;
ascii:  r = dec: 114, oct: 0162, hex: 0x72;
ascii:  R = dec:  82, oct: 0122, hex: 0x52;
ascii:  t = dec: 116, oct: 0164, hex: 0x74;
ascii:  T = dec:  84, oct: 0124, hex: 0x54;
ascii:  y = dec: 121, oct: 0171, hex: 0x79;
ascii:  Y = dec:  89, oct: 0131, hex: 0x59;
ascii:  u = dec: 117, oct: 0165, hex: 0x75;
ascii:  U = dec:  85, oct: 0125, hex: 0x55;
ascii:  i = dec: 105, oct: 0151, hex: 0x69;
ascii:  I = dec:  73, oct: 0111, hex: 0x49;
ascii:  o = dec: 111, oct: 0157, hex: 0x6f;
ascii:  O = dec:  79, oct: 0117, hex: 0x4f;
ascii:  p = dec: 112, oct: 0160, hex: 0x70;
ascii:  P = dec:  80, oct: 0120, hex: 0x50;
ascii:  [ = dec:  91, oct: 0133, hex: 0x5b;
ascii:  { = dec: 123, oct: 0173, hex: 0x7b;
ascii:  ] = dec:  93, oct: 0135, hex: 0x5d;
ascii:  } = dec: 125, oct: 0175, hex: 0x7d;
ascii:  \ = dec:  92, oct: 0134, hex: 0x5c;
ascii:  | = dec: 124, oct: 0174, hex: 0x7c;
ascii:  a = dec:  97, oct: 0141, hex: 0x61;
ascii:  A = dec:  65, oct: 0101, hex: 0x41;
ascii:  s = dec: 115, oct: 0163, hex: 0x73;
ascii:  S = dec:  83, oct: 0123, hex: 0x53;
ascii:  d = dec: 100, oct: 0144, hex: 0x64;
ascii:  D = dec:  68, oct: 0104, hex: 0x44;
ascii:  f = dec: 102, oct: 0146, hex: 0x66;
ascii:  F = dec:  70, oct: 0106, hex: 0x46;
ascii:  g = dec: 103, oct: 0147, hex: 0x67;
ascii:  G = dec:  71, oct: 0107, hex: 0x47;
ascii:  h = dec: 104, oct: 0150, hex: 0x68;
ascii:  H = dec:  72, oct: 0110, hex: 0x48;
ascii:  j = dec: 106, oct: 0152, hex: 0x6a;
ascii:  J = dec:  74, oct: 0112, hex: 0x4a;
ascii:  k = dec: 107, oct: 0153, hex: 0x6b;
ascii:  K = dec:  75, oct: 0113, hex: 0x4b;
ascii:  l = dec: 108, oct: 0154, hex: 0x6c;
ascii:  L = dec:  76, oct: 0114, hex: 0x4c;
ascii:  ; = dec:  59, oct: 073, hex: 0x3b;
ascii:  : = dec:  58, oct: 072, hex: 0x3a;
ascii:  " = dec:  34, oct: 042, hex: 0x22;
ascii:  z = dec: 122, oct: 0172, hex: 0x7a;
ascii:  Z = dec:  90, oct: 0132, hex: 0x5a;
ascii:  x = dec: 120, oct: 0170, hex: 0x78;
ascii:  X = dec:  88, oct: 0130, hex: 0x58;
ascii:  c = dec:  99, oct: 0143, hex: 0x63;
ascii:  C = dec:  67, oct: 0103, hex: 0x43;
ascii:  v = dec: 118, oct: 0166, hex: 0x76;
ascii:  V = dec:  86, oct: 0126, hex: 0x56;
ascii:  b = dec:  98, oct: 0142, hex: 0x62;
ascii:  B = dec:  66, oct: 0102, hex: 0x42;
ascii:  n = dec: 110, oct: 0156, hex: 0x6e;
ascii:  N = dec:  78, oct: 0116, hex: 0x4e;
ascii:  m = dec: 109, oct: 0155, hex: 0x6d;
ascii:  M = dec:  77, oct: 0115, hex: 0x4d;
ascii:  , = dec:  44, oct: 054, hex: 0x2c;
ascii:  < = dec:  60, oct: 074, hex: 0x3c;
ascii:  . = dec:  46, oct: 056, hex: 0x2e;
ascii:  > = dec:  62, oct: 076, hex: 0x3e;
ascii:  / = dec:  47, oct: 057, hex: 0x2f;
ascii:  ? = dec:  63, oct: 077, hex: 0x3f;

#Gerrit

-- 
[email-masked]

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/