Show ASCII table: Difference between revisions

From Rosetta Code
Content added Content deleted
(added Factor)
(→‎{{header|Perl 6}}: Display wiki-table instead of ASCII art)
Line 188: Line 188:


=={{header|Perl 6}}==
=={{header|Perl 6}}==
<lang perl6>constant \N = 16;
constant \cell = 5;
constant $top = join '─' x cell, '┌', '┬' xx N-1, '┐';
constant $mid = join '─' x cell, '├', '┼' xx N-1, '┤';
constant $bot = join '─' x cell, '└', '┴' xx N-1, '┘';


Alternately, and perhaps more usefully, output as a wiki-table rather than ASCII art:
sub row (*@row) { '│' ~ (join '│', @row».&center) ~ "│\n" }

<lang perl6>constant \N = 16;
sub center ($s){
my $c = cell - $s.chars;
my $pad = ' ' x ceiling($c/2);
sprintf "%{cell}s", "$s$pad";
}


sub name ($n) {
sub name ($n) {
given $n {
given $n {
when * < 33 { (0x2400 + $n).chr }
when * < 33 { (0x2400 + $n).chr } # display symbol names instead of invisible glyphs
when 127 { '' }
when 124 { '<nowiki>|</nowiki>' } # meh. deal with wiki formatting
default { $n.chr }
when 127 { '␡' } # another invisible glyph
default { $n.chr }
}
}
}
}


say '{|class="wikitable" style="text-align:center;background-color:hsl(39, 90%, 95%)"';
my @rows = map -> @row {

row(@row».fmt(" %02X")) ~
for (^128).rotor(N) -> @row {
row(@row».fmt("%03d")) ~
say '|-';
row(@row».&name)
printf("|%d\<br/>0x%02X\<br/>\<big>\<big>%s\</big>\</big>\n", $_, $_, .&name)
}, ^128 .rotor: N;
for @row;
}


say $top;
say '|}';</lang>
print @rows.join: "$mid\n";
say $bot;</lang>
{{out}}
{{out}}
{|class="wikitable" style="text-align:center;background-color:hsl(39, 90%, 95%)"
<pre>┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐
|-
│ 00 │ 01 │ 02 │ 03 │ 04 │ 05 │ 06 │ 07 │ 08 │ 09 │ 0A │ 0B │ 0C │ 0D │ 0E │ 0F │
|0<br/>0x00<br/><big><big>␀</big></big>
│ 000 │ 001 │ 002 │ 003 │ 004 │ 005 │ 006 │ 007 │ 008 │ 009 │ 010 │ 011 │ 012 │ 013 │ 014 │ 015 │
|1<br/>0x01<br/><big><big>␁</big></big>
│ ␀ │ ␁ │ ␂ │ ␃ │ ␄ │ ␅ │ ␆ │ ␇ │ ␈ │ ␉ │ ␊ │ ␋ │ ␌ │ ␍ │ ␎ │ ␏ │
|2<br/>0x02<br/><big><big>␂</big></big>
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
|3<br/>0x03<br/><big><big>␃</big></big>
│ 10 │ 11 │ 12 │ 13 │ 14 │ 15 │ 16 │ 17 │ 18 │ 19 │ 1A │ 1B │ 1C │ 1D │ 1E │ 1F │
|4<br/>0x04<br/><big><big>␄</big></big>
│ 016 │ 017 │ 018 │ 019 │ 020 │ 021 │ 022 │ 023 │ 024 │ 025 │ 026 │ 027 │ 028 │ 029 │ 030 │ 031 │
|5<br/>0x05<br/><big><big>␅</big></big>
│ ␐ │ ␑ │ ␒ │ ␓ │ ␔ │ ␕ │ ␖ │ ␗ │ ␘ │ ␙ │ ␚ │ ␛ │ ␜ │ ␝ │ ␞ │ ␟ │
|6<br/>0x06<br/><big><big>␆</big></big>
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
|7<br/>0x07<br/><big><big>␇</big></big>
│ 20 │ 21 │ 22 │ 23 │ 24 │ 25 │ 26 │ 27 │ 28 │ 29 │ 2A │ 2B │ 2C │ 2D │ 2E │ 2F │
|8<br/>0x08<br/><big><big>␈</big></big>
│ 032 │ 033 │ 034 │ 035 │ 036 │ 037 │ 038 │ 039 │ 040 │ 041 │ 042 │ 043 │ 044 │ 045 │ 046 │ 047 │
|9<br/>0x09<br/><big><big>␉</big></big>
│ ␠ │ ! │ " │ # │ $ │ % │ & │ ' │ ( │ ) │ * │ + │ , │ - │ . │ / │
|10<br/>0x0A<br/><big><big>␊</big></big>
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
|11<br/>0x0B<br/><big><big>␋</big></big>
│ 30 │ 31 │ 32 │ 33 │ 34 │ 35 │ 36 │ 37 │ 38 │ 39 │ 3A │ 3B │ 3C │ 3D │ 3E │ 3F │
|12<br/>0x0C<br/><big><big>␌</big></big>
│ 048 │ 049 │ 050 │ 051 │ 052 │ 053 │ 054 │ 055 │ 056 │ 057 │ 058 │ 059 │ 060 │ 061 │ 062 │ 063 │
|13<br/>0x0D<br/><big><big>␍</big></big>
│ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ : │ ; │ < │ = │ > │ ? │
|14<br/>0x0E<br/><big><big>␎</big></big>
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
|15<br/>0x0F<br/><big><big>␏</big></big>
│ 40 │ 41 │ 42 │ 43 │ 44 │ 45 │ 46 │ 47 │ 48 │ 49 │ 4A │ 4B │ 4C │ 4D │ 4E │ 4F │
|-
│ 064 │ 065 │ 066 │ 067 │ 068 │ 069 │ 070 │ 071 │ 072 │ 073 │ 074 │ 075 │ 076 │ 077 │ 078 │ 079 │
|16<br/>0x10<br/><big><big>␐</big></big>
│ @ │ A │ B │ C │ D │ E │ F │ G │ H │ I │ J │ K │ L │ M │ N │ O │
|17<br/>0x11<br/><big><big>␑</big></big>
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
|18<br/>0x12<br/><big><big>␒</big></big>
│ 50 │ 51 │ 52 │ 53 │ 54 │ 55 │ 56 │ 57 │ 58 │ 59 │ 5A │ 5B │ 5C │ 5D │ 5E │ 5F │
|19<br/>0x13<br/><big><big>␓</big></big>
│ 080 │ 081 │ 082 │ 083 │ 084 │ 085 │ 086 │ 087 │ 088 │ 089 │ 090 │ 091 │ 092 │ 093 │ 094 │ 095 │
|20<br/>0x14<br/><big><big>␔</big></big>
│ P │ Q │ R │ S │ T │ U │ V │ W │ X │ Y │ Z │ [ │ \ │ ] │ ^ │ _ │
|21<br/>0x15<br/><big><big>␕</big></big>
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
|22<br/>0x16<br/><big><big>␖</big></big>
│ 60 │ 61 │ 62 │ 63 │ 64 │ 65 │ 66 │ 67 │ 68 │ 69 │ 6A │ 6B │ 6C │ 6D │ 6E │ 6F │
|23<br/>0x17<br/><big><big>␗</big></big>
│ 096 │ 097 │ 098 │ 099 │ 100 │ 101 │ 102 │ 103 │ 104 │ 105 │ 106 │ 107 │ 108 │ 109 │ 110 │ 111 │
|24<br/>0x18<br/><big><big>␘</big></big>
│ ` │ a │ b │ c │ d │ e │ f │ g │ h │ i │ j │ k │ l │ m │ n │ o │
|25<br/>0x19<br/><big><big>␙</big></big>
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
|26<br/>0x1A<br/><big><big>␚</big></big>
│ 70 │ 71 │ 72 │ 73 │ 74 │ 75 │ 76 │ 77 │ 78 │ 79 │ 7A │ 7B │ 7C │ 7D │ 7E │ 7F │
|27<br/>0x1B<br/><big><big>␛</big></big>
│ 112 │ 113 │ 114 │ 115 │ 116 │ 117 │ 118 │ 119 │ 120 │ 121 │ 122 │ 123 │ 124 │ 125 │ 126 │ 127 │
|28<br/>0x1C<br/><big><big>␜</big></big>
│ p │ q │ r │ s │ t │ u │ v │ w │ x │ y │ z │ { │ | │ } │ ~ │ ␡ │
|29<br/>0x1D<br/><big><big>␝</big></big>
└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘</pre>
|30<br/>0x1E<br/><big><big>␞</big></big>
|31<br/>0x1F<br/><big><big>␟</big></big>
|-
|32<br/>0x20<br/><big><big>␠</big></big>
|33<br/>0x21<br/><big><big>!</big></big>
|34<br/>0x22<br/><big><big>"</big></big>
|35<br/>0x23<br/><big><big>#</big></big>
|36<br/>0x24<br/><big><big>$</big></big>
|37<br/>0x25<br/><big><big>%</big></big>
|38<br/>0x26<br/><big><big>&</big></big>
|39<br/>0x27<br/><big><big>'</big></big>
|40<br/>0x28<br/><big><big>(</big></big>
|41<br/>0x29<br/><big><big>)</big></big>
|42<br/>0x2A<br/><big><big>*</big></big>
|43<br/>0x2B<br/><big><big>+</big></big>
|44<br/>0x2C<br/><big><big>,</big></big>
|45<br/>0x2D<br/><big><big>-</big></big>
|46<br/>0x2E<br/><big><big>.</big></big>
|47<br/>0x2F<br/><big><big>/</big></big>
|-
|48<br/>0x30<br/><big><big>0</big></big>
|49<br/>0x31<br/><big><big>1</big></big>
|50<br/>0x32<br/><big><big>2</big></big>
|51<br/>0x33<br/><big><big>3</big></big>
|52<br/>0x34<br/><big><big>4</big></big>
|53<br/>0x35<br/><big><big>5</big></big>
|54<br/>0x36<br/><big><big>6</big></big>
|55<br/>0x37<br/><big><big>7</big></big>
|56<br/>0x38<br/><big><big>8</big></big>
|57<br/>0x39<br/><big><big>9</big></big>
|58<br/>0x3A<br/><big><big>:</big></big>
|59<br/>0x3B<br/><big><big>;</big></big>
|60<br/>0x3C<br/><big><big><</big></big>
|61<br/>0x3D<br/><big><big>=</big></big>
|62<br/>0x3E<br/><big><big>></big></big>
|63<br/>0x3F<br/><big><big>?</big></big>
|-
|64<br/>0x40<br/><big><big>@</big></big>
|65<br/>0x41<br/><big><big>A</big></big>
|66<br/>0x42<br/><big><big>B</big></big>
|67<br/>0x43<br/><big><big>C</big></big>
|68<br/>0x44<br/><big><big>D</big></big>
|69<br/>0x45<br/><big><big>E</big></big>
|70<br/>0x46<br/><big><big>F</big></big>
|71<br/>0x47<br/><big><big>G</big></big>
|72<br/>0x48<br/><big><big>H</big></big>
|73<br/>0x49<br/><big><big>I</big></big>
|74<br/>0x4A<br/><big><big>J</big></big>
|75<br/>0x4B<br/><big><big>K</big></big>
|76<br/>0x4C<br/><big><big>L</big></big>
|77<br/>0x4D<br/><big><big>M</big></big>
|78<br/>0x4E<br/><big><big>N</big></big>
|79<br/>0x4F<br/><big><big>O</big></big>
|-
|80<br/>0x50<br/><big><big>P</big></big>
|81<br/>0x51<br/><big><big>Q</big></big>
|82<br/>0x52<br/><big><big>R</big></big>
|83<br/>0x53<br/><big><big>S</big></big>
|84<br/>0x54<br/><big><big>T</big></big>
|85<br/>0x55<br/><big><big>U</big></big>
|86<br/>0x56<br/><big><big>V</big></big>
|87<br/>0x57<br/><big><big>W</big></big>
|88<br/>0x58<br/><big><big>X</big></big>
|89<br/>0x59<br/><big><big>Y</big></big>
|90<br/>0x5A<br/><big><big>Z</big></big>
|91<br/>0x5B<br/><big><big>[</big></big>
|92<br/>0x5C<br/><big><big>\</big></big>
|93<br/>0x5D<br/><big><big>]</big></big>
|94<br/>0x5E<br/><big><big>^</big></big>
|95<br/>0x5F<br/><big><big>_</big></big>
|-
|96<br/>0x60<br/><big><big>`</big></big>
|97<br/>0x61<br/><big><big>a</big></big>
|98<br/>0x62<br/><big><big>b</big></big>
|99<br/>0x63<br/><big><big>c</big></big>
|100<br/>0x64<br/><big><big>d</big></big>
|101<br/>0x65<br/><big><big>e</big></big>
|102<br/>0x66<br/><big><big>f</big></big>
|103<br/>0x67<br/><big><big>g</big></big>
|104<br/>0x68<br/><big><big>h</big></big>
|105<br/>0x69<br/><big><big>i</big></big>
|106<br/>0x6A<br/><big><big>j</big></big>
|107<br/>0x6B<br/><big><big>k</big></big>
|108<br/>0x6C<br/><big><big>l</big></big>
|109<br/>0x6D<br/><big><big>m</big></big>
|110<br/>0x6E<br/><big><big>n</big></big>
|111<br/>0x6F<br/><big><big>o</big></big>
|-
|112<br/>0x70<br/><big><big>p</big></big>
|113<br/>0x71<br/><big><big>q</big></big>
|114<br/>0x72<br/><big><big>r</big></big>
|115<br/>0x73<br/><big><big>s</big></big>
|116<br/>0x74<br/><big><big>t</big></big>
|117<br/>0x75<br/><big><big>u</big></big>
|118<br/>0x76<br/><big><big>v</big></big>
|119<br/>0x77<br/><big><big>w</big></big>
|120<br/>0x78<br/><big><big>x</big></big>
|121<br/>0x79<br/><big><big>y</big></big>
|122<br/>0x7A<br/><big><big>z</big></big>
|123<br/>0x7B<br/><big><big>{</big></big>
|124<br/>0x7C<br/><big><big><nowiki>|</nowiki></big></big>
|125<br/>0x7D<br/><big><big>}</big></big>
|126<br/>0x7E<br/><big><big>~</big></big>
|127<br/>0x7F<br/><big><big>␡</big></big>
|}


=={{header|Ring}}==
=={{header|Ring}}==

Revision as of 23:00, 9 August 2018

Show ASCII table is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
Task

Show ASCII character set from values 32 to 127 in table format.


C

Translation of: Go

<lang c>#include <stdio.h>

int main() {

   int i, j;
   char k[4];
   for (i = 0; i < 16; ++i) {
       for (j = 32 + i; j < 128; j += 16) {
           switch (j) {
               default:  sprintf(k, "%c", j); break;
               case 32:  sprintf(k, "Spc"); break;
               case 127: sprintf(k, "Del"); break;                
           }
           printf("%3d : %-3s   ", j, k);
       }
       printf("\n");    
   }                    
   return 0;

}</lang>

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

Factor

Idiomatic version

Works with: Factor version 0.98

<lang factor>USING: combinators formatting io kernel math math.ranges pair-rocket sequences ; IN: rosetta-code.ascii-table

row-values ( n -- seq ) [ 32 + ] [ 112 + ] bi 16 <range> ;
ascii>output ( n -- str )
   { 32 => [ "Spc" ] 127 => [ "Del" ] [ "" 1sequence ] } case ;
   
print-row ( n -- )
   row-values [ dup ascii>output "%3d : %-3s   " printf ] each nl ;
   
print-ascii-table ( -- ) 16 <iota> [ print-row ] each ;

MAIN: print-ascii-table</lang>

Go translation

Translation of: Go
Works with: Factor version 0.98

<lang factor>USING: combinators formatting io kernel math math.ranges pair-rocket sequences ; IN: rosetta-code.ascii-table

main ( -- )
   16 <iota> [
       32 + 127 16 <range> [
           dup {
               32  => [ "Spc" ]
               127 => [ "Del" ]
               [ "" 1sequence ]
           } case
           "%3d : %-3s   " printf
       ] each
       nl
   ] each

MAIN: main</lang>

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

Go

<lang go>package main

import "fmt"

func main() {

   for i := 0; i < 16; i++ {
       for j := 32 + i; j < 128; j += 16 {
           k := string(j)
           switch j {
           case 32:
               k = "Spc"
           case 127:
               k = "Del"
           }
           fmt.Printf("%3d : %-3s   ", j, k)
       }
       fmt.Println()
   }

} </lang>

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

Kotlin

Translation of: Go

<lang scala>// Version 1.2.60

fun main(args: Array<String>) {

   for (i in 0..15) {
       for (j in 32 + i..127 step 16) {
           val k = when (j) {
               32   -> "Spc"
               127  -> "Del"
               else -> j.toChar().toString()
           }
           System.out.printf("%3d : %-3s   ", j, k)
       }
       println()
   }

}</lang>

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

Perl 6

Alternately, and perhaps more usefully, output as a wiki-table rather than ASCII art:

<lang perl6>constant \N = 16;

sub name ($n) {

   given $n {
       when * < 33 { (0x2400 + $n).chr }    # display symbol names instead of invisible glyphs
       when 124    { '|' } # meh. deal with wiki formatting
       when 127    { '␡' }                  # another invisible glyph
       default     { $n.chr }
   }

}

say '{|class="wikitable" style="text-align:center;background-color:hsl(39, 90%, 95%)"';

for (^128).rotor(N) -> @row {

   say '|-';
   printf("|%d\
0x%02X\
\\%s\\\n", $_, $_, .&name) for @row;

}

say '|}';</lang>

Output:
0
0x00
1
0x01
2
0x02
3
0x03
4
0x04
5
0x05
6
0x06
7
0x07
8
0x08
9
0x09
10
0x0A
11
0x0B
12
0x0C
13
0x0D
14
0x0E
15
0x0F
16
0x10
17
0x11
18
0x12
19
0x13
20
0x14
21
0x15
22
0x16
23
0x17
24
0x18
25
0x19
26
0x1A
27
0x1B
28
0x1C
29
0x1D
30
0x1E
31
0x1F
32
0x20
33
0x21
!
34
0x22
"
35
0x23
#
36
0x24
$
37
0x25
%
38
0x26
&
39
0x27
'
40
0x28
(
41
0x29
)
42
0x2A
*
43
0x2B
+
44
0x2C
,
45
0x2D
-
46
0x2E
.
47
0x2F
/
48
0x30
0
49
0x31
1
50
0x32
2
51
0x33
3
52
0x34
4
53
0x35
5
54
0x36
6
55
0x37
7
56
0x38
8
57
0x39
9
58
0x3A
:
59
0x3B
;
60
0x3C
<
61
0x3D
=
62
0x3E
>
63
0x3F
?
64
0x40
@
65
0x41
A
66
0x42
B
67
0x43
C
68
0x44
D
69
0x45
E
70
0x46
F
71
0x47
G
72
0x48
H
73
0x49
I
74
0x4A
J
75
0x4B
K
76
0x4C
L
77
0x4D
M
78
0x4E
N
79
0x4F
O
80
0x50
P
81
0x51
Q
82
0x52
R
83
0x53
S
84
0x54
T
85
0x55
U
86
0x56
V
87
0x57
W
88
0x58
X
89
0x59
Y
90
0x5A
Z
91
0x5B
[
92
0x5C
\
93
0x5D
]
94
0x5E
^
95
0x5F
_
96
0x60
`
97
0x61
a
98
0x62
b
99
0x63
c
100
0x64
d
101
0x65
e
102
0x66
f
103
0x67
g
104
0x68
h
105
0x69
i
106
0x6A
j
107
0x6B
k
108
0x6C
l
109
0x6D
m
110
0x6E
n
111
0x6F
o
112
0x70
p
113
0x71
q
114
0x72
r
115
0x73
s
116
0x74
t
117
0x75
u
118
0x76
v
119
0x77
w
120
0x78
x
121
0x79
y
122
0x7A
z
123
0x7B
{
124
0x7C
|
125
0x7D
}
126
0x7E
~
127
0x7F

Ring

<lang ring>

  1. Project : Show Ascii table

load "guilib.ring" load "stdlib.ring"

decarr = newlist(16,6) ascarr = newlist(16,6)

new qapp

       {
       win1 = new qwidget() {
                 setwindowtitle("Show Ascii table")
                 setgeometry(100,100,800,600)
                 for n = 1 to 16
                      for m = 1 to 6
                           decarr[n][m] = new qpushbutton(win1) {
                                                 x = 150+m*60
                                                 y = 30 + n*30
                                                 ind = string((m-1)*16+n+31)
                                                 setgeometry(x,y,30,30)
                                                 settext(ind)
                                                 }
                      next
                 next
                 for n = 1 to 16
                      for m = 1 to 6
                           ascarr[n][m] = new qpushbutton(win1) {
                                                 x = 180+m*60
                                                 y = 30 + n*30
                                                 ind = (m-1)*16+n+31
                                                 setgeometry(x,y,30,30)
                                                 if ind = 32
                                                    settext("Spc")
                                                    loop
                                                 ok
                                                 if ind = 127
                                                    settext("Del")
                                                    loop
                                                 ok
                                                 settext(char(ind))
                                                 }
                      next
                 next
                 show()
       }
       exec()
       }

</lang> Output:

Show Ascii table