Function File: ascii ()
Function File: ascii (columns)

Print ASCII table.

If this function is called without any input argument and without any output argument then prints a nice ASCII-table (excluding special characters with hexcode 0x00 to 0x20). The input argument columns specifies the number of columns and defaults to 4.

If it is called with one output argument then return the ASCII table as a string without displaying anything. Run demo ascii for examples.

See also: char, isascii, toascii.

Demonstration 1

The following code

 ## Display pretty table of conversion between ASCII, decimal and hexadecimal
 ascii ()

Produces the following output

vtab =

 Dec Hex Chr  Dec Hex Chr  Dec Hex Chr  Dec Hex Chr 
----------------------------------------------------
  32  20       56  38   8   80  50   P  104  68   h 
  33  21   !   57  39   9   81  51   Q  105  69   i 
  34  22   "   58  3A   :   82  52   R  106  6A   j 
  35  23   #   59  3B   ;   83  53   S  107  6B   k 
  36  24   $   60  3C   <   84  54   T  108  6C   l 
  37  25   %   61  3D   =   85  55   U  109  6D   m 
  38  26   &   62  3E   >   86  56   V  110  6E   n 
  39  27   '   63  3F   ?   87  57   W  111  6F   o 
  40  28   (   64  40   @   88  58   X  112  70   p 
  41  29   )   65  41   A   89  59   Y  113  71   q 
  42  2A   *   66  42   B   90  5A   Z  114  72   r 
  43  2B   +   67  43   C   91  5B   [  115  73   s 
  44  2C   ,   68  44   D   92  5C   \  116  74   t 
  45  2D   -   69  45   E   93  5D   ]  117  75   u 
  46  2E   .   70  46   F   94  5E   ^  118  76   v 
  47  2F   /   71  47   G   95  5F   _  119  77   w 
  48  30   0   72  48   H   96  60   `  120  78   x 
  49  31   1   73  49   I   97  61   a  121  79   y 
  50  32   2   74  4A   J   98  62   b  122  7A   z 
  51  33   3   75  4B   K   99  63   c  123  7B   { 
  52  34   4   76  4C   L  100  64   d  124  7C   | 
  53  35   5   77  4D   M  101  65   e  125  7D   } 
  54  36   6   78  4E   N  102  66   f  126  7E   ~ 
  55  37   7   79  4F   O  103  67   g  127  7F    
  56  38   8   80  50   P  104  68   h  128  80

Demonstration 2

The following code

 ## Display 6 columns table of conversion between ASCII, decimal and hexadecimal
 ascii (6)

Produces the following output

vtab =

 Dec Hex Chr  Dec Hex Chr  Dec Hex Chr  Dec Hex Chr  Dec Hex Chr  Dec Hex Chr 
------------------------------------------------------------------------------
  32  20       48  30   0   64  40   @   80  50   P   96  60   `  112  70   p 
  33  21   !   49  31   1   65  41   A   81  51   Q   97  61   a  113  71   q 
  34  22   "   50  32   2   66  42   B   82  52   R   98  62   b  114  72   r 
  35  23   #   51  33   3   67  43   C   83  53   S   99  63   c  115  73   s 
  36  24   $   52  34   4   68  44   D   84  54   T  100  64   d  116  74   t 
  37  25   %   53  35   5   69  45   E   85  55   U  101  65   e  117  75   u 
  38  26   &   54  36   6   70  46   F   86  56   V  102  66   f  118  76   v 
  39  27   '   55  37   7   71  47   G   87  57   W  103  67   g  119  77   w 
  40  28   (   56  38   8   72  48   H   88  58   X  104  68   h  120  78   x 
  41  29   )   57  39   9   73  49   I   89  59   Y  105  69   i  121  79   y 
  42  2A   *   58  3A   :   74  4A   J   90  5A   Z  106  6A   j  122  7A   z 
  43  2B   +   59  3B   ;   75  4B   K   91  5B   [  107  6B   k  123  7B   { 
  44  2C   ,   60  3C   <   76  4C   L   92  5C   \  108  6C   l  124  7C   | 
  45  2D   -   61  3D   =   77  4D   M   93  5D   ]  109  6D   m  125  7D   } 
  46  2E   .   62  3E   >   78  4E   N   94  5E   ^  110  6E   n  126  7E   ~ 
  47  2F   /   63  3F   ?   79  4F   O   95  5F   _  111  6F   o  127  7F    
  48  30   0   64  40   @   80  50   P   96  60   `  112  70   p  128  80

Demonstration 3

The following code

 ## Return a string with a pretty formatted table (but don't display it)
 table = ascii (1)
 display (table (65, :));

Produces the following output

table =

 Dec Hex Chr 
-------------
  32  20     
  33  21   ! 
  34  22   " 
  35  23   # 
  36  24   $ 
  37  25   % 
  38  26   & 
  39  27   ' 
  40  28   ( 
  41  29   ) 
  42  2A   * 
  43  2B   + 
  44  2C   , 
  45  2D   - 
  46  2E   . 
  47  2F   / 
  48  30   0 
  49  31   1 
  50  32   2 
  51  33   3 
  52  34   4 
  53  35   5 
  54  36   6 
  55  37   7 
  56  38   8 
  57  39   9 
  58  3A   : 
  59  3B   ; 
  60  3C   < 
  61  3D   = 
  62  3E   > 
  63  3F   ? 
  64  40   @ 
  65  41   A 
  66  42   B 
  67  43   C 
  68  44   D 
  69  45   E 
  70  46   F 
  71  47   G 
  72  48   H 
  73  49   I 
  74  4A   J 
  75  4B   K 
  76  4C   L 
  77  4D   M 
  78  4E   N 
  79  4F   O 
  80  50   P 
  81  51   Q 
  82  52   R 
  83  53   S 
  84  54   T 
  85  55   U 
  86  56   V 
  87  57   W 
  88  58   X 
  89  59   Y 
  90  5A   Z 
  91  5B   [ 
  92  5C   \ 
  93  5D   ] 
  94  5E   ^ 
  95  5F   _ 
  96  60   ` 
  97  61   a 
  98  62   b 
  99  63   c 
 100  64   d 
 101  65   e 
 102  66   f 
 103  67   g 
 104  68   h 
 105  69   i 
 106  6A   j 
 107  6B   k 
 108  6C   l 
 109  6D   m 
 110  6E   n 
 111  6F   o 
 112  70   p 
 113  71   q 
 114  72   r 
 115  73   s 
 116  74   t 
 117  75   u 
 118  76   v 
 119  77   w 
 120  78   x 
 121  79   y 
 122  7A   z 
 123  7B   { 
 124  7C   | 
 125  7D   } 
 126  7E   ~ 
 127  7F    
 128  80   € 

  94  5E   ^

Package: miscellaneous