Show ASCII table: Difference between revisions

(added Zig)
(31 intermediate revisions by 17 users not shown)
Line 437:
 
=={{header|ALGOL 68}}==
<syntaxhighlight lang="algol68">BEGIN
# generate an ascii table for characters 32 - 127 #
FOR c FROM 32 TO 32 + 15 DO
INT char count := 1;
FOR cach FROM 32c BY 16 TO 127c + ( 16 * 5 ) DO
print( ( whole( cach, -4 )
, ": "
, IF cach = 32 THEN "SPC"
ELIF cach = 127 THEN "DEL"
ELSE " " + REPR cach + " "
FI
)
);
OD;
IF char count = 0 THEN print( ( newline ) ) FI;
print( ( charnewline count PLUSAB 1) ) MODAB 6
OD
END</syntaxhighlight>
{{out}}
<pre> 32: SPC 3348: !0 3464: "@ 3580: #P 3696: $` 37112: %p
3833: &! 3949: '1 4065: (A 4181: )Q 4297: *a 43113: +q
4434: ," 4550: -2 4666: .B 4782: /R 4898: 0b 49114: 1r
5035: 2# 51: 3 5267: 4C 5383: 5S 5499: 6c 55115: 7s
5636: 8$ 5752: 94 5868: :D 5984: ;T 60100: < d 61116: =t
6237: >% 6353: ?5 6469: @E 6585: AU 66101: B e 67117: Cu
6838: D& 6954: E6 70: F 7186: GV 72102: H f 73118: Iv
7439: J' 7555: K7 7671: LG 7787: MW 78103: N g 79119: Ow
8040: P( 8156: Q8 8272: RH 8388: SX 84104: T h 85120: Ux
8641: V) 8757: W9 8873: XI 89: Y 90105: Z i 91121: [y
9242: \* 9358: ]: 9474: ^J 9590: _Z 96106: ` j 97122: az
9843: b+ 9959: c; 100 75: dK 10191: e[ 102107: fk 103123: g{
104 44: h, 105 60: i< 106 76: jL 10792: k\ 108: l 109124: m|
110 45: n- 111 61: o= 112 77: pM 11393: q] 114109: rm 115125: s}
116 46: t. 117 62: u> 118 78: vN 11994: w^ 120110: xn 121126: y~
122 47: z/ 123 63: {? 124 79: |O 125 95: }_ 126111: ~o 127: DEL</pre>
</pre>
 
=={{header|ALGOL W}}==
This assumes the ASCII character set is used by the Algol W compiler/runtime - the original Algol W implementation used EBCDIC.
<syntaxhighlight lang="algolw">begin
<syntaxhighlight lang="algolw">% generate an ascii table for chars 32 - 127 %
for i := 32 until 32 + 15 do begin
integer cPos;
cPos := 0write();
for ic := 32i step 16 until 127i + ( 16 * 5 ) do begin
ifwriteon( cPosi_w := 3, s_w := 0, thenc, ": " write();
cPosif := ( cPos + 1 )c rem= 6; 32 then writeon( "Spc ")
writeon(else i_wif c := 3,127 s_wthen := 0, i,writeon( ":Del " );
ifelse i = 32 then writeon( code( c ), "Spc " )
end for_ach
else if i = 127 then writeon( "Del " )
end for_i.
else writeon( code( i ), " " )
</syntaxhighlight>
end for_i
end.</syntaxhighlight>
{{out}}
<pre>
<pre> 32: Spc 33: ! 34: " 35: # 36: $ 37: %
3832: &Spc 3948: '0 4064: (@ 4180: )P 4296: * ` 43112: +p
4433: ,! 4549: -1 4665: .A 4781: /Q 4897: 0a 49113: 1q
5034: 2" 5150: 32 5266: 4B 5382: 5R 5498: 6 b 55114: 7r
5635: 8# 5751: 93 5867: :C 5983: ;S 6099: < c 61115: =s
6236: >$ 6352: ?4 6468: @D 6584: AT 66100: B d 67116: Ct
6837: D% 6953: E5 7069: FE 7185: GU 72101: H e 73117: Iu
7438: J& 7554: K6 7670: LF 7786: MV 78102: N f 79118: Ov
8039: P' 8155: Q7 8271: RG 8387: SW 84103: T g 85119: Uw
8640: V( 8756: W8 8872: XH 8988: YX 90104: Z h 91120: [x
9241: \) 9357: ]9 9473: ^I 9589: _Y 96105: ` i 97121: ay
9842: b* 9958: c: 100 74: dJ 10190: eZ 102106: fj 103122: gz
104 43: h+ 105 59: i; 106 75: jK 107 91: k[ 108107: lk 109123: m{
110 44: n, 111 60: o< 112 76: pL 11392: q\ 114108: rl 115124: s|
116 45: t- 117 61: u= 118 77: vM 11993: w] 120109: xm 121125: y}
122 46: z. 123 62: {> 124 78: |N 125 94: }^ 126110: ~n 127126: Del</pre>~
47: / 63: ? 79: O 95: _ 111: o 127: Del
</pre>
 
=={{header|APL}}==
Line 1,239 ⟶ 1,241:
 
=={{header|BASIC}}==
==={{header|BASIC256}}===
<syntaxhighlight lang="basic">10 DEFINT I,J: DEFSTR S: DIM S(2)
<syntaxhighlight lang="vb">for i = 32 to 47
for j = i to i + 80 step 16
begin case
case j = 32
s$ = "Spc"
case j = 127
s$ = "Del"
else
s$ = chr(j)
end case
print rjust(" "+string(j),5); ": "; ljust(s$,3);
next j
print
next i</syntaxhighlight>
 
==={{header|Chipmunk Basic}}===
{{works with|Chipmunk Basic|3.6.4}}
{{works with|QBasic}}
<syntaxhighlight lang="qbasic">10 cls
20 for r = 0 to 15
30 for c = 1 to 6
40 a = 16+r+c*16
50 print right$(" "+str$(a),4)": " chr$(a)tab (10*c);
60 next c
70 print
80 next r</syntaxhighlight>
{{out}}
<pre> 32: 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: ⌂</pre>
 
==={{header|GW-BASIC}}===
{{works with|BASICA}}
<syntaxhighlight lang="gwbasic">10 DEFINT I,J: DEFSTR S: DIM S(2)
20 S(0)="* "
30 S(1)="Spc"
Line 1,267 ⟶ 1,316:
46: . 62: > 78: N 94: ^ 110: n 126: ~
47: / 63: ? 79: O 95: _ 111: o 127: Del</pre>
 
==={{header|IS-BASIC}}===
<syntaxhighlight lang="is-basic">100 TEXT 80
110 FOR R=0 TO 15
120 FOR C=32+R TO 112+R STEP 16
130 PRINT USING "###":C;:PRINT ": ";CHR$(C),
140 NEXT
150 PRINT
160 NEXT</syntaxhighlight>
 
==={{header|MSX Basic}}===
The [[#GW-BASIC|GW-BASIC]] solution works without any changes.
 
==={{header|QBasic}}===
The [[#QB64|QB64]] solution works without any changes.
 
==={{header|Run BASIC}}===
{{works with|Just BASIC}}
{{works with|Liberty BASIC}}
<syntaxhighlight lang="vb">for i = 32 to 47
for j = i to i + 80 step 16
select case j
case 32
s$ = "Spc"
case 127
s$ = "Del"
case else
s$ = chr$(j)
end select
print right$(" "+str$(j),4); ": "; s$; space$(3);
next j
print
next i</syntaxhighlight>
 
==={{header|True BASIC}}===
<syntaxhighlight lang="qbasic">FOR i = 32 TO 47
FOR j = i TO i+80 STEP 16
SELECT CASE j
CASE 32
LET s$ = "Spc"
CASE 127
LET s$ = "Del"
CASE else
LET s$ = CHR$(j)
END SELECT
PRINT USING "###: ### ": j, s$;
NEXT j
PRINT
NEXT</syntaxhighlight>
{{out}}
<pre>Same as QB64 entry.</pre>
 
==={{header|XBasic}}===
{{works with|Windows XBasic}}
<syntaxhighlight lang="qbasic">PROGRAM "ASCII table"
VERSION "0.0000"
 
DECLARE FUNCTION Entry ()
 
FUNCTION Entry ()
FOR i = 32 TO 47
FOR j = i TO i + 80 STEP 16
SELECT CASE j
CASE 32
s$ = "Spc"
CASE 127
s$ = "Del"
CASE ELSE
s$ = CHR$(j)
END SELECT
PRINT RJUST$(" "+STRING(j),4); ": "; LJUST$(s$,3);
NEXT j
PRINT
NEXT i
END FUNCTION
END PROGRAM</syntaxhighlight>
 
==={{header|Yabasic}}===
<syntaxhighlight lang="vb">for i = 32 to 47
for j = i to i + 80 step 16
s$ = chr$(j)
if j = 32 s$ = "Spc"
if j = 127 s$ = "Del"
print str$(j, "#####"), ": ", s$;
next j
print
next i</syntaxhighlight>
 
=={{header|BaCon}}==
Line 1,431 ⟶ 1,567:
#include <iostream>
 
inline constexpr auto HEIGHT = 16;
 
#defineinline HEIGHTconstexpr auto WIDTH 16 = 6;
inline constexpr auto ASCII_START = 32;
#define WIDTH 6
#define ASCII_START 32
#define ASCII_END 128
// ASCII special characters
inline constexpr auto SPACE = 32;
#define SPACE 32
inline constexpr auto DELETE = 127;
#define DELETE 127
 
std::string displayAscii(intchar ascii) {
switch (ascii) {
case SPACE: return "Spc";
case DELETE: return "SpcDel";
default: return std::string(1, ascii);
case DELETE:
return "Del";}
default:
return std::string(1,char(ascii));
}
}
 
int main(void) {
for (std::size_t row = 0; row < HEIGHT; ++row) {
 
for (intstd::size_t rowcol = 0; rowcol < HEIGHTWIDTH; ++rowcol) {
for(int col = 0; col < WIDTH; const auto ascii = ASCII_START + row + col) {* HEIGHT;
std::cout << std::right << std::setw(3) << ascii << " : " << std::left << std::setw(6) << displayAscii(ascii);
int ascii = ASCII_START + row + col*HEIGHT;
}
std::cout << std::right << std::setw(3) << ascii << " : " \
<< std::leftcout << std::setw(6) << displayAscii(ascii)'\n';
}
std::cout << std::endl;
}
}</syntaxhighlight>
{{out}}
Line 2,018 ⟶ 2,147:
47 : / 63 : ? 79 : O 95 : _ 111 : o 127 : Del
</pre>
 
=={{header|Draco}}==
<syntaxhighlight lang="draco">proc write_item(byte n) void:
*char chrstr = "* ";
chrstr* := pretend(n, char);
write(n:3, " : ",
case n
incase 32: "Spc "
incase 127: "Del "
default: chrstr
esac)
corp
 
proc main() void:
byte row, col;
for row from 32 upto 47 do
for col from row by 16 upto 127 do
write_item(col)
od;
writeln()
od
corp</syntaxhighlight>
{{out}}
<pre> 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</pre>
 
=={{header|EasyLang}}==
{{trans|AWK}}
 
<syntaxhighlight lang="easylang">
numfmt 0 3
for i range0 16
for j = 32 + i step 16 to 127
if j = 32
x$ = "Spc"
elif j = 127
x$ = "Del"
else
x$ = strchar j & " "
.
write j & ": " & x$
.
print ""
.
</syntaxhighlight>
 
=={{header|Ecstasy}}==
<syntaxhighlight lang="java">
module testShowAsciiTable {
{
@Inject Console console;
void run() {
for (Int offset : 0..<16) {
for (Int ascii = 32+offset; :ascii 0..< 128; ascii += 16) {
{
for (Int ascii = 32+offset; ascii < 128; ascii += 16)
{
console.print($|{ascii.toString().rightJustify(3)}/\
|{ascii.toByte().toByteArray()}: \
|{new Char(ascii).quoted().leftJustify(5)}
, suppressNewline=True);
}
console.print();
}
}
}
}
</syntaxhighlight>
 
Line 2,060 ⟶ 2,244:
47/0x2F: '/' 63/0x3F: '?' 79/0x4F: 'O' 95/0x5F: '_' 111/0x6F: 'o' 127/0x7F: '\d'
</pre>
 
 
=={{header|Excel}}==
Line 2,894 ⟶ 3,077:
=={{header|Fōrmulæ}}==
 
{{FormulaeEntry|page=https://formulae.org/?script=examples/Show_ASCII_table}}
Fōrmulæ programs are not textual, visualization/edition of programs is done showing/manipulating structures but not text. Moreover, there can be multiple visual representations of the same program. Even though it is possible to have textual representation &mdash;i.e. XML, JSON&mdash; they are intended for storage and transfer purposes more than visualization and edition.
 
'''Solution'''
Programs in Fōrmulæ are created/edited online in its [https://formulae.org website], However they run on execution servers. By default remote servers are used, but they are limited in memory and processing power, since they are intended for demonstration and casual use. A local server can be downloaded and installed, it has no limitations (it runs in your own computer). Because of that, example programs can be fully visualized and edited, but some of them will not run if they require a moderate or heavy computation/memory resources, and no local server is being used.
 
[[File:Fōrmulæ - Show ASCII table 01.png]]
In '''[https://formulae.org/?example=Show_ASCII_table this]''' page you can see the program(s) related to this task and their results.
 
[[File:Fōrmulæ - Show ASCII table 02.png]]
 
=={{header|FutureBasic}}==
Line 2,906 ⟶ 3,090:
 
local fn ASCIITable as CFStringRef
NSinteger i
'~'1
CFStringRef temp
NSinteger i
CFStringRef temp
CFMutableStringRef mutStr = fn MutableStringWithCapacity( 0 )
 
for i = 32 to 127
CFMutableStringRef mutStr = fn MutableStringWithCapacity( 0 )
temp = fn StringWithFormat( @"%c", i )
for i = 32 to 127
if i == 32 then temp = @"Spc"
temp = fn StringWithFormat( @"%c", i )
if i == 32127 then temp = @"SpcDel"
MutableStringAppendString( mutStr, fn StringWithFormat( @"%-1d : %@\n", i, temp ) )
if i == 127 then temp = @"Del"
next
MutableStringAppendString( mutStr, fn StringWithFormat( @"%-1d : %@\n", i, temp ) )
next
CFArrayRef colArr = fn StringComponentsSeparatedByString( mutStr, @"\n" )
 
CFArrayRef colArr = fn StringComponentsSeparatedByStringMutableStringSetString( mutStr, @"\n" )
for i = 0 to 15
MutableStringSetString( mutStr, @"" )
ObjectRef col0 = fn StringUTF8String( fn ArrayObjectAtIndex( colArr, i ) )
for i = 0 to 15
ObjectRef col0col1 = fn StringUTF8String( fn ArrayObjectAtIndex( colArr, i + 16 ) )
ObjectRef col1col2 = fn StringUTF8String( fn ArrayObjectAtIndex( colArr, i + 1632 ) )
ObjectRef col2col3 = fn StringUTF8String( fn ArrayObjectAtIndex( colArr, i + 3248 ) )
ObjectRef col3col4 = fn StringUTF8String( fn ArrayObjectAtIndex( colArr, i + 4864 ) )
ObjectRef col4col5 = fn StringUTF8String( fn ArrayObjectAtIndex( colArr, i + 6480 ) )
MutableStringAppendString( mutStr, fn StringWithFormat( @"%-10s %-10s %-10s %-10s %-10s %-10s\n", col0, col1, col2, col3, col4, col5 ) )
ObjectRef col5 = fn StringUTF8String( fn ArrayObjectAtIndex( colArr, i + 80 ) )
next
MutableStringAppendString( mutStr, fn StringWithFormat( @"%-10s %-10s %-10s %-10s %-10s %-10s\n", col0, col1, col2, col3, col4, col5 ) )
next
end fn = fn StringWithString( mutStr )
 
Line 2,954 ⟶ 3,137:
47 : / 63 : ? 79 : O 95 : _ 111 : o 127 : Del
</pre>
 
 
=={{header|Go}}==
Line 3,083 ⟶ 3,265:
47 : / 63 : ? 79 : O 95 : _ 111 : o 127 : Del </pre>
 
=={{headerHeader|IS-BASICInsitux}}==
<syntaxhighlight lang="is-basicinsitux">100 TEXT 80
(-> (for i (range 16)
110 FOR R=0 TO 15
120 FOR C=32+R TO 112 j (range (+R STEPi 32) 128 16)
(let k (match j 32 "Spc" 127 "Del" (str (char-code j) " ")))
130 PRINT USING "###":C;:PRINT ": ";CHR$(C),
(strn ((< j 100) " ") j " : " k))
140 NEXT
(partition 6)
150 PRINT
(map (join " "))
160 NEXT</syntaxhighlight>
(join "\n"))
</syntaxhighlight>
{{out}}
<pre>
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
</pre>
 
=={{header|J}}==
<pre> ;"1 ((_6_9{.":),': ',8 u:]ucp)each 32+|:i.6 16
32: 48: 0 64: @ 80: P 96: ` 112: p
33: ! 49: 1 65: A 81: Q 97: a 113: q
Line 3,153 ⟶ 3,356:
116: t 117: u 118: v 119: w 120: x 121: y
122: z 123: { 124: | 125: } 126: ~ 127: Del
</pre>
You could also do this:<br />
<syntaxhighlight lang="java">
String printASCIITable() {
StringBuilder string = new StringBuilder();
String newline = System.lineSeparator();
string.append("dec hex binary oct char").append(newline);
for (int decimal = 32; decimal <= 127; decimal++) {
string.append(format(decimal));
switch (decimal) {
case 32 -> string.append("[SPACE]");
case 127 -> string.append("[DELETE]");
default -> string.append((char) decimal);
}
string.append(newline);
}
return string.toString();
}
 
String format(int value) {
return "%-3d %01$-2x %7s %01$-3o ".formatted(value, Integer.toBinaryString(value));
}
</syntaxhighlight>
<pre>
dec hex binary oct char
32 20 100000 40 [SPACE]
33 21 100001 41 !
34 22 100010 42 "
35 23 100011 43 #
36 24 100100 44 $
37 25 100101 45 %
38 26 100110 46 &
39 27 100111 47 '
40 28 101000 50 (
41 29 101001 51 )
42 2a 101010 52 *
43 2b 101011 53 +
44 2c 101100 54 ,
45 2d 101101 55 -
46 2e 101110 56 .
47 2f 101111 57 /
48 30 110000 60 0
49 31 110001 61 1
50 32 110010 62 2
51 33 110011 63 3
52 34 110100 64 4
53 35 110101 65 5
54 36 110110 66 6
55 37 110111 67 7
56 38 111000 70 8
57 39 111001 71 9
58 3a 111010 72 :
59 3b 111011 73 ;
60 3c 111100 74 <
61 3d 111101 75 =
62 3e 111110 76 >
63 3f 111111 77 ?
64 40 1000000 100 @
65 41 1000001 101 A
66 42 1000010 102 B
67 43 1000011 103 C
68 44 1000100 104 D
69 45 1000101 105 E
70 46 1000110 106 F
71 47 1000111 107 G
72 48 1001000 110 H
73 49 1001001 111 I
74 4a 1001010 112 J
75 4b 1001011 113 K
76 4c 1001100 114 L
77 4d 1001101 115 M
78 4e 1001110 116 N
79 4f 1001111 117 O
80 50 1010000 120 P
81 51 1010001 121 Q
82 52 1010010 122 R
83 53 1010011 123 S
84 54 1010100 124 T
85 55 1010101 125 U
86 56 1010110 126 V
87 57 1010111 127 W
88 58 1011000 130 X
89 59 1011001 131 Y
90 5a 1011010 132 Z
91 5b 1011011 133 [
92 5c 1011100 134 \
93 5d 1011101 135 ]
94 5e 1011110 136 ^
95 5f 1011111 137 _
96 60 1100000 140 `
97 61 1100001 141 a
98 62 1100010 142 b
99 63 1100011 143 c
100 64 1100100 144 d
101 65 1100101 145 e
102 66 1100110 146 f
103 67 1100111 147 g
104 68 1101000 150 h
105 69 1101001 151 i
106 6a 1101010 152 j
107 6b 1101011 153 k
108 6c 1101100 154 l
109 6d 1101101 155 m
110 6e 1101110 156 n
111 6f 1101111 157 o
112 70 1110000 160 p
113 71 1110001 161 q
114 72 1110010 162 r
115 73 1110011 163 s
116 74 1110100 164 t
117 75 1110101 165 u
118 76 1110110 166 v
119 77 1110111 167 w
120 78 1111000 170 x
121 79 1111001 171 y
122 7a 1111010 172 z
123 7b 1111011 173 {
124 7c 1111100 174 |
125 7d 1111101 175 }
126 7e 1111110 176 ~
127 7f 1111111 177 [DELETE]
</pre>
 
Line 3,665 ⟶ 3,989:
end
prt(Tbl) # format and print table on console</syntaxhighlight>
 
=={{header|K}}==
{{works with|ngn/k}}
<syntaxhighlight lang=K>`0:"\n"/" "/'+6 16#{-6$($x),-2$`c$x}'32+!96
32 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</syntaxhighlight>
 
=={{header|Kotlin}}==
Line 3,701 ⟶ 4,045:
46 : . 62 : > 78 : N 94 : ^ 110 : n 126 : ~
47 : / 63 : ? 79 : O 95 : _ 111 : o 127 : Del </pre>
 
=={{header|Lambdatalk}}==
<syntaxhighlight lang="scheme">
{def format
{lambda {:i :c}
{if {< :i 100}
then {span {@ style="color:white;"}.}:i : :c
else :i : :c}}}
-> format
 
{S.map
{lambda {:i}
{div}
{S.map {lambda {:i}
{if {= :i 32} then {format :i {span {@ style="color:#fff;"}.}}
else {if {= :i 123} then {format :i left brace}
else {if {= :i 125} then {format :i right brace}
else {if {= :i 127} then {format :i del}
else {format :i {code2char :i}}}}}}}
{S.serie {+ 32 :i} 127 16}}}
{S.serie 0 15}}
 
32 : 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 : left brace
44 : , 60 : < 76 : L 92 : \ 108 : l 124 : |
45 : - 61 : = 77 : M 93 : ] 109 : m 125 : right brace
46 : . 62 : > 78 : N 94 : ^ 110 : n 126 : ~
47 : / 63 : ? 79 : O 95 : _ 111 : o 127 : del
 
</syntaxhighlight>
 
 
 
=={{header|Lang}}==
Line 3,747 ⟶ 4,133:
=={{header|langur}}==
{{trans|Go}}
{{works with|langur|0.6.8}}
<syntaxhighlight lang="langur">for .i of 16 {
for .j = 31 + .i ; .j < 128 ; .j += 16 {
val .L = givenswitch(.j; 32: "spc"; 127: "del"; cp2s .j)
write $"\{.j:3;} : \{.L:-4;}"
}
writeln()
Line 3,892 ⟶ 4,277:
 
</pre>
 
=={{header|MACRO-11}}==
<syntaxhighlight lang="macro11"> .TITLE ASCTAB
.MCALL .PRINT,.EXIT
ASCTAB::MOV #40,R5
MOV #20,R4
1$: MOV #NBUF,R1
MOV R5,R2
2$: MOV #-1,R3
3$: INC R3
SUB #12,R2
BCC 3$
ADD #72,R2
MOVB R2,-(R1)
MOV R3,R2
BNE 2$
CMP R1,#NUM
BEQ 4$
MOVB #40,-(R1)
4$: .PRINT #NUM
CMP #40,R5
BEQ 5$
CMP #177,R5
BEQ 6$
MOVB R5,CHR
.PRINT #CHR
BR 7$
5$: .PRINT #SPC
BR 7$
6$: .PRINT #DEL
7$: ADD #20,R5
CMP R5,#200
BLT 1$
SUB #137,R5
.PRINT #NL
DEC R4
BNE 1$
.EXIT
NUM: .ASCII / /
NBUF: .ASCII /: /<200>
CHR: .ASCII /. /<200>
SPC: .ASCII /SPC /<200>
DEL: .ASCII /DEL /<200>
NL: .ASCIZ //
.END ASCTAB</syntaxhighlight>
{{out}}
<pre> 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</pre>
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
Line 3,913 ⟶ 4,360:
47: / 63: ? 79: O 95: _ 111: o 127: Del </pre>
 
=={{header|Miranda}}==
<syntaxhighlight lang="miranda">main :: [sys_message]
main = [Stdout table]
 
table :: [char]
table = lay [concat [item n | n<-[row, (row+16)..127]] | row<-[32..47]]
 
item :: num->[char]
item n = num ++ " : " ++ desc
where num = reverse (take 3 (reverse (shownum n) ++ repeat ' '))
desc = "Spc ", if n = 32
= "Del ", if n = 127
= decode n : " ", otherwise</syntaxhighlight>
{{out}}
<pre> 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</pre>
 
=={{header|MiniScript}}==
Line 3,968 ⟶ 4,445:
122 : z 123 : { 124 : | 125 : } 126 : ~ 127 : DEL
</pre>
 
=={{header|Modula-2}}==
<syntaxhighlight lang="modula2">MODULE AsciiTable;
FROM InOut IMPORT Write, WriteCard, WriteString, WriteLn;
 
VAR row, col: CARDINAL;
 
PROCEDURE WriteItem(n: CARDINAL);
BEGIN
WriteCard(n, 3);
WriteString(": ");
CASE n OF
32: WriteString("Spc ")
| 127: WriteString("Del ")
ELSE
Write(CHR(n));
WriteString(" ")
END
END WriteItem;
 
BEGIN
FOR row := 32 TO 47 DO
FOR col := row TO 127 BY 16 DO
WriteItem(col)
END;
WriteLn
END
END AsciiTable.</syntaxhighlight>
{{out}}
<pre> 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</pre>
 
=={{header|Nanoquery}}==
Line 4,219 ⟶ 4,741:
 
=={{header|PL/M}}==
<syntaxhighlight lang="pli">100H: /* SHOW AN ASCII TABLE FROM 32 TO 127 */
100H: /* SHOW AN ASCII TABLE FROM 32 TO 127 */
/* CP/M BDOS SYSTEM CALL */
BDOS: PROCEDURE( FN, ARG ); DECLARE FN BYTE, ARG ADDRESS; GOTO 5; END;
Line 4,235 ⟶ 4,758:
END PR$BYTE;
/* ASCII TABLE */
DECLARE ( A, C ) BYTE;
DO C = 32 TO 12732 + 15;
CALLDO PR$BYTE(A = C TO C + ( 16 * 5 ) BY 16;
CALL PR$STRINGBYTE( .': $'A );
IF C = 32 THEN CALL PR$STRING( .'SPC: $' );
ELSE IF C A = 127 32 THEN CALL PR$STRING( .'DELSPC$' );
ELSE DOIF A = 127 THEN CALL PR$STRING( .'DEL$' );
CALLELSE PR$CHAR( ' ' )DO;
CALL PR$CHAR( ' C ' );
CALL PR$CHAR( ' 'A );
CALL PR$CHAR( ' ' );
END;
END;
IF ( ( C - 31 ) MOD 6 ) = 0 THEN CALL PR$STRING( .( 0DH, 0AH, '$' ) );
END;
EOF
EOF</syntaxhighlight>
</syntaxhighlight>
{{out}}
<pre>
032: SPC 033048: !0 034064: "@ 035080: #P 036096: $` 037112: %p
038033: &! 039049: '1 040065: (A 041081: )Q 042097: *a 043113: +q
044034: ," 045050: -2 046066: .B 047082: /R 048098: 0b 049114: 1r
050035: 2# 051: 3 052067: 4C 053083: 5S 054099: 6c 055115: 7s
056036: 8$ 057052: 94 058068: :D 059084: ;T 060100: <d 061116: =t
062037: >% 063053: ?5 064069: @E 065085: AU 066101: Be 067117: Cu
068038: D& 069054: E6 070: F 071086: GV 072102: Hf 073118: Iv
074039: J' 075055: K7 076071: LG 077087: MW 078103: Ng 079119: Ow
080040: P( 081056: Q8 082072: RH 083088: SX 084104: Th 085120: Ux
086041: V) 087057: W9 088073: XI 089: Y 090105: Zi 091121: [y
092042: \* 093058: ]: 094074: ^J 095090: _Z 096106: `j 097122: az
098043: b+ 099059: c; 100075: dK 101091: e[ 102107: fk 103123: g{
104044: h, 105060: i< 106076: jL 107092: k\ 108: l 109124: m|
110045: n- 111061: o= 112077: pM 113093: q] 114109: rm 115125: s}
116046: t. 117062: u> 118078: vN 119094: w^ 120110: xn 121126: y~
122047: z/ 123063: {? 124079: |O 125095: }_ 126111: ~o 127: DEL
</pre>
 
Line 4,707 ⟶ 5,233:
 
=={{header|QB64}}==
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
<syntaxhighlight lang="qbasic">DIM s AS STRING
 
Line 5,583 ⟶ 6,111:
46 : . 62 : > 78 : N 94 : ^ 110 : n 126 : ~
47 : / 63 : ? 79 : O 95 : _ 111 : o 127 : Del </pre>
 
=={{header|VTL-2}}==
<syntaxhighlight lang="vtl2">10 C=32
20 L=16
30 #=C>100*50
40 $=32
50 ?=C
60 ?=": ";
70 #=C=32*120
80 #=C=127*140
90 $=C
100 ?=" ";
110 #=150
120 ?="Spc ";
130 #=150
140 ?="Del ";
150 C=C+16
160 #=C<128*30
170 C=C-95
180 L=L-1
190 ?=""
200 #=L=0=0*30</syntaxhighlight>
{{out}}
<pre> 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</pre>
 
=={{header|Wren}}==
{{trans|Go}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Fmt
 
for (i in 0...16) {
Line 5,658 ⟶ 6,225:
0E . > N ^ n ~
0F / ? O _ o
</pre>
=={{header|Z80 Assembly}}==
{{works with|CP/M 3.1|YAZE-AG-2.51.2 Z80 emulator}}
{{works with|ZSM4 macro assembler|YAZE-AG-2.51.2 Z80 emulator}}
Use the /S8 switch on the ZSM4 assembler for 8 significant characters for labels and names
<syntaxhighlight lang="z80">
;
; Print ASCII table using Z80 assembly language
;
; Runs under CP/M 3.1 on YAZE-AG-2.51.2 Z80 emulator
; Assembled with zsm4 on same emulator/OS, uses macro capabilities of said assembler
; Created with vim under Windows
;
; Thanks to https://wikiti.brandonw.net for the idea for the conversion routine hl -> decimal ASCII
;
; 2023-04-04 Xorph
;
 
;
; Useful definitions
;
 
bdos equ 05h ; Call to CP/M BDOS function
strdel equ 6eh ; Set string delimiter
wrtstr equ 09h ; Write string to console
 
numrows equ 16d ; Number of rows for output
numcols equ 6d ; Number of columns for output
 
nul equ 00h ; ASCII control characters
esc equ 1bh
cr equ 0dh
lf equ 0ah
 
cnull equ '0' ; ASCII character constants
spc equ 20h
del equ 7fh
 
;
; Macros for BDOS calls
;
 
setdel macro char ; Set string delimiter to char
ld c,strdel
ld e,char
call bdos
endm
 
print macro msg ; Output string to console
ld c,wrtstr
ld de,msg
call bdos
endm
 
newline macro ; Print newline
ld c,wrtstr
ld de,crlf
call bdos
endm
 
pushall macro ; Save all registers to stack
push af
push bc
push de
push hl
push ix
push iy
endm
 
popall macro ; Recall all registers from stack
pop iy
pop ix
pop hl
pop de
pop bc
pop af
endm
 
;
; =====================
; Start of main program
; =====================
;
 
cseg
 
asciitab:
setdel nul ; Set string terminator to nul ('\0') - '$' is default in CP/M
 
ld a,spc ; First ASCII code to print
loop:
ld (char),a ; Put ASCII code in output placeholder
ld h,0 ; Register pair hl is used for printing the number, register h remains 0
ld l,a ; Put ASCII code in hl for decimal conversion
ld ix,buffer
call dispHL ; Create decimal representation
 
ld d,3d ; Pad decimal representation to 3 places with leading blanks
ld e,' ' ; Registers d and e are modified in macro, so assign each time
ld hl,buffer
ld bc,format
call padstrl
 
print format ; Print the whole thing
print colon
 
chkspc:
ld a,(char) ; Load again, register a was lost during BDOS calls
cp spc ; Check if Spc
jr nz,chkdel ; If not, check if Del
print txtspc ; If yes, print the text for Spc
jr nextcol ; ...and skip to the next column
 
chkdel:
ld a,(char) ; Load again, register a was lost during BDOS calls
cp del ; Check if Del
jr nz,printc ; If not, print normal char
print txtdel ; If yes, print the text for Del
jr nextcol ; ...and skip to the next column
 
printc:
print char ; Normal char
 
nextcol:
ld a,(curcol) ; Increase output column
inc a
cp numcols ; If last column, go to next row
jr z,nextrow
ld (curcol),a ; Save column counter
ld a,(char) ; Increase ASCII code by the number of rows for next column in same row
add a,numrows
jr loop ; Next code
 
nextrow:
newline ; Display next row
xor a ; Set column counter back to 0
ld (curcol),a
ld a,(currow) ; Increase row counter
inc a
cp numrows ; When last row has been finished, we are done
jr z,exitprg
 
ld (currow),a ; Save row counter
ld a,(char) ; Set ASCII code back to starting code of next row
sub a,numrows * (numcols - 1d) - 1d
jp loop ; Use jp instead of jr because of jump distance!
 
exitprg:
newline
ret ; Return to CP/M
 
;
; ===================
; End of main program
; ===================
;
 
;
; Helper routines - notice that the Z80 does not have a divide instruction
; Notice further that CP/M does not have any support for pretty-printing
; formatted numbers and stuff like that. So we have to do all this by hand...
;
 
;
; Converts the value (unsigned int) in register hl to its decimal representation
; Register ix has memory address of target for converted value
; String is terminated with nul character (\0)
;
 
dispHL:
pushall
ld b,1 ; Flag for leading '0'
irp x,<-10000,-1000,-100,-10,-1>
ld de,x ; Subtract powers of 10 and determine digit
call calcdig
endm
 
ld a,nul ; Terminate result string with nul
ld (ix+0),a
 
popall
ret ; End of conversion routine
 
calcdig:
ld a,cnull-1 ; Determine the digit character
incrdig:
inc a ; Start with '0'
add hl,de ; As long as subtraction is possible, increment digit character
jr c,incrdig
 
sbc hl,de ; If negative, undo last subtraction and continue with remainder
cp cnull ; Check for leading '0', these are ignored
jr nz,adddig
bit 0,b ; Use bit instruction for check if flag set, register a contains digit
ret nz ; If '0' found and flag set, it is a leading '0' and we return
adddig:
ld b,0 ; Reset flag for leading '0', we are now outputting digits
ld (ix+0),a ; Store character in memory and set ix to next location
inc ix
 
ret ; End of conversion helper routine
 
;
; Formats a string to the specified minimum width with the specified filler character
; Register hl has memory address of nul-terminated string
; Register bc has memory address of target for padded string
; Register d has width
; Register e has filler character/byte
; Padding is on the left (function is intended for padding integer numbers)
;
 
padstrl:
pushall
push hl ; Save address of source for copy later on
ld a,d ; Check if width is 0, just copy string if so
cp 0
jr z,copysrc
ld a,nul ; Search for end of string. Each non-nul character decrements d
 
findnul:
cp (hl)
jr z,nulfound ; Found end of string, d contains number of padding to add
dec d
jr z,copysrc
inc hl
jr findnul ; Repeat with next character
 
nulfound:
ld a,e ; Store as many padding characters to target as specified in register d
inspad:
ld (bc),a
inc bc ; Move to next memory address and decrease d
dec d
jr nz,inspad
 
copysrc:
pop hl ; Transfer source to target, bc points to first memory address after padding
movechar:
ld a,(hl)
ld (bc),a
inc hl
inc bc
cp nul ; Check if nul character copied
jr nz,movechar ; If no, repeat with next character
 
popall
ret ; End of padding routine
 
;
; ================
; Data definitions
; ================
;
 
dseg
 
crlf: defb cr,lf,nul ; Generic newline
buffer: defs 10 ; Buffer for conversion of number to text
format: defs 10 ; Formatted number for output
colon: defz ' : ' ; Separator number/character, nul-terminated
char: defz ' ' ; Placeholder for ASCII character, nul-terminated
txtspc: defz 'Spc ' ; Space character 20h
txtdel: defz 'Del ' ; Del character 7fh
currow: defb 0d ; Current row
curcol: defb 0d ; Current column
</syntaxhighlight>
 
{{out}}
<pre>
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
</pre>
 
=={{header|Zig}}==
{{trans|Java}}
<syntaxhighlight lang="zig">const stdprint = @import("std").debug.print;
pub fn main() void {
var i: u8 = 33;
std.debug.print(" 32: Spc", .{});
while (i < 127) : (i += 1) {
print("{:03}: {c} ", if.{ (i, <i 100}) {;
if (@mod(i, 6) == 1) {
std.debug.print(" {d}: {c} ", .{ i, i });
print("\n", .{} else {);
std.debug.print("{d}: {c} ", .{ i, i });
}
if (@mod(i, 6) == 1) {
std.debug.print("\n", .{});
}
}
}
std.debug.print("127: Del", .{});
print("127: Del", .{});
}</syntaxhighlight>
 
885

edits