Show ASCII table: Difference between revisions
m
syntax highlighting fixup automation
(add BQN) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 11:
{{trans|Python}}
<
L(j) (32 + i .. 127).step(16)
String k
Line 21:
k = Char(code' j)
print(‘#3 : #<3’.format(j, k), end' ‘’)
print()</
{{out}}
Line 44:
=={{header|6502 Assembly}}==
<
; task : show ascii table
; language: 6502 Assembly
Line 163:
column .byte 0
ascii .byte 0
</syntaxhighlight>
=={{header|8080 Assembly}}==
<
mvi a,32 ; Start with space
mvi d,16 ; 16 lines
Line 234:
spc: db 'Spc ',0 ; Space
del: db 'Del ',0 ; Del
chr: db '* ',0 ; Placeholder for character</
{{out}}
Line 258:
=={{header|8086 Assembly}}==
<
bits 16
putch: equ 2h
Line 315:
spc: db 'Spc ',0 ; Space
del: db 'Del ',0 ; Del
chr: db '* ',0 ; Placeholder for character</
{{out}}
Line 338:
=={{header|Action!}}==
Atari 8-bit computers use [https://en.wikipedia.org/wiki/ATASCII ATASCII] character set which is a variation of ASCII.
<
BYTE
count=[96],rows=[16],
Line 372:
PutE()
OD
RETURN</
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Show_ASCII_table.png Screenshot from Atari 8-bit computer]
Line 395:
=={{header|Ada}}==
<
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
Line 417:
New_Line;
end loop;
end Ascii_Table;</
{{out}}
<pre> 32 : Spc 48 : 0 64 : @ 80 : P 96 : ` 112 : p
Line 437:
=={{header|ALGOL 68}}==
<
# generate an ascii table for characters 32 - 127 #
INT char count := 1;
Line 452:
( char count PLUSAB 1 ) MODAB 6
OD
END</
{{out}}
<pre> 32: SPC 33: ! 34: " 35: # 36: $ 37: %
Line 472:
=={{header|ALGOL W}}==
<
% generate an ascii table for chars 32 - 127 %
integer cPos;
Line 484:
else writeon( code( i ), " " )
end for_i
end.</
{{out}}
<pre> 32: Spc 33: ! 34: " 35: # 36: $ 37: %
Line 505:
=={{header|APL}}==
<
{{out}}
Line 527:
=={{header|AppleScript}}==
<
on asciiTable()
script row
Line 782:
set my text item delimiters to dlm
str
end unlines</
{{Out}}
<pre> 32 : Spc 48 : 0 64 : @ 80 : P 96 : ` 112 : p
Line 802:
=={{header|Applesoft BASIC}}==
This is similar to the Commodore BASIC program in that it clears the screen and displays the version of BASIC. It uses enterable Applesoft BASIC to embed a 6502 machine language routine that XORs $87 with the character stored at $41 and prints the character.<
10 LET X = 256 * PEEK (104)
11 LET X = X + PEEK (103) + 7
Line 821:
70 LET N$ = RIGHT$ (N$,4)
80 PRINT N$":" CHR$ (A + R);
90 NEXT C,R: PRINT</
The 6502 routine is embedded at line 0 and is used to display the string "!TFOSORCIM" backwards.
<
EOR #$87 ; I READ
JMP $DB59 ; LY RND</
=={{header|ARM Assembly}}==
Thanks to Keith of [https://www.chibiakumas.com ChibiAkumas] for creating the GBA bitmap font and I/O routines.
<
.equ CursorY,0x02000001
ProgramStart:
Line 1,117:
.byte 0x00,0x00,0x00,0x20,0x52,0x0C,0x00,0x00 ; 7E ~
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ; 7F
.byte 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF ; 80</
{{out}}
Line 1,124:
=={{header|Arturo}}==
<
k: ø
case [num]
Line 1,133:
prints pad ~"|num|: |k|" 10
if 1 = num%6 -> print ""
]</
{{out}}
Line 1,155:
=={{header|AutoHotkey}}==
<
MessageText := ;The text to display in the final message box.
Line 1,184:
}
MsgBox, % MessageText ;Displays a message box with the ASCII conversion table, from the MessageText variable
return</
{{out}}
<pre>
Line 1,207:
{{works with|GAWK}}
{{works with|MAWK}}
<
# syntax: MAWK -f SHOW_ASCII_TABLE.AWK
BEGIN {
Line 1,219:
print ""
}
}</
{{out}}
<pre> 32: SPC 48: 0 64: @ 80: P 96: ` 112: p
Line 1,239:
=={{header|BASIC}}==
<
20 S(0)="* "
30 S(1)="Spc"
Line 1,249:
90 NEXT J
100 PRINT
110 NEXT I</
{{out}}
<pre> 32: Spc 48: 0 64: @ 80: P 96: ` 112: p
Line 1,269:
=={{header|BaCon}}==
<
FOR i = 32+j TO 127 STEP 16
PRINT i FORMAT " %3d - ";
Line 1,282:
NEXT
PRINT
NEXT</
{{out}}
Line 1,303:
=={{header|BCPL}}==
<
let str(n) =
Line 1,315:
writef(str(j), j, j)
wrch('*N')
$)</
{{out}}
<pre> 32: Spc 48: 0 64: @ 80: P 96: ` 112: p
Line 1,336:
=={{header|BQN}}==
The final result is a 2D array of characters which is output line by line with <code>•Out</code>.
<
J←{𝕨∾' '∾𝕩}´
_pad←{(𝕗×·⌈´≠¨)⊸(↑¨)}
•Out˘J˘J¨⍉6‿16⥊<˘⍉(∾⟜':'¨¯1 _pad •Fmt¨32+↕96)≍1 _pad chs</
<syntaxhighlight lang="text"> 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
Line 1,355:
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</
=={{header|C}}==
{{trans|Go}}
<
int main() {
Line 1,375:
}
return 0;
}</
{{out}}
<pre> 32 : Spc 48 : 0 64 : @ 80 : P 96 : ` 112 : p
Line 1,395:
=={{header|C++}}==
<
#include <iomanip>
#include <iostream>
Line 1,429:
std::cout << std::endl;
}
}</
{{out}}
<pre>
Line 1,451:
=={{header|C sharp}}==
<
using static System.Linq.Enumerable;
Line 1,464:
string Text(int index) => index == 32 ? "Sp" : index == 127 ? "Del" : (char)index + "";
}
}</
{{out}}
<pre> 32 : Sp 48 : 0 64 : @ 80 : P 96 : ` 112 : p
Line 1,484:
=={{header|Caché ObjectScript}}==
<
; this is 96 characters, so do 6 columns of 16
for i = 32:1:127 {
Line 1,501:
}
quit</
{{out}}
Line 1,528:
Further down, the code will be modified to handle the more general case of a grid where the number of codes to be displayed doesn't match the product of the numbers of rows and columns in the desired grid. That case is made a little trickier by the desire to print the table in "column-major order", which seems the friendlier to the end-user reading the table.
<syntaxhighlight lang="clojure">
(defn cell [code]
(let [text (get {32 "Spc", 127 "Del"} code (char code))]
Line 1,547:
(defn pr-ascii-table [n-cols st-code end-code]
(println (ascii-table n-cols st-code end-code)))
</syntaxhighlight>
{{out}}
Line 1,593:
There are 2 output examples, the first simply creates a grid with an incomplete final column. The second case additionally demonstrates the ability to modify the range of ASCII codes displayed.
<syntaxhighlight lang="clojure">
(defn cell [code]
(if (nil? code)
Line 1,616:
(defn pr-ascii-table [n-cols st-code end-code]
(println (ascii-table n-cols st-code end-code)))
</syntaxhighlight>
{{out}}
Line 1,656:
=={{header|CLU}}==
<
if n=32 then return("Spc")
elseif n=127 then return("Del")
Line 1,673:
stream$putl(po, "")
end
end start_up</
{{out}}
<pre> 32: Spc 48: 0 64: @ 80: P 96: ` 112: p
Line 1,695:
{{works with|OpenCOBOL|3.1.2}}
Uses free form syntax.
<syntaxhighlight lang="cobol">
IDENTIFICATION DIVISION.
PROGRAM-ID. CHARSET.
Line 1,718:
END-PERFORM.
END PROGRAM CHARSET.
</syntaxhighlight>
{{out}}
Line 1,726:
=={{header|Commodore BASIC}}==
<
110 PRINT CHR$(14);:REM CHARACTER SET 2
120 PRINT "COMMODORE 64 - BASIC V2"
Line 1,738:
200 PRINT
210 NEXT R
</syntaxhighlight>
{{out}}
[[File:c64asciitable.jpg]]
Line 1,745:
=={{header|Common Lisp}}==
<
(setq endVal 127)
(setq cols 6)
Line 1,762:
(if (> lower upper) '() (cons lower (get-range (+ 1 lower) upper))))
(mapcar #'print-val (get-range startVal endVal))</
{{out}}
<pre> 32: SPC 33: ! 34: " 35: # 36: $ 37: %
Line 1,782:
=={{header|Cowgol}}==
<
# Print number with preceding space if <100 and trailing colon
Line 1,814:
end if;
end loop;
print_nl();</
{{out}}
Line 1,837:
=={{header|D}}==
{{trans|C}}
<
void main() {
Line 1,856:
writeln;
}
}</
{{out}}
<pre> 32 : Spc 48 : 0 64 : @ 80 : P 96 : ` 112 : p
Line 1,879:
{{Works with|GNU dc|1.3.95}}
<
## for initcode condcode incrcode body
Line 1,910:
] lfx
[]pP
] lfx</
{{out}}
<pre>
Line 1,934:
{{Trans|Go}}
<syntaxhighlight lang="delphi">
program Show_Ascii_table;
Line 1,965:
end.
</syntaxhighlight>
{{out}}
Line 1,994:
{{Works with|Office 365 betas 2021}}
<
=LAMBDA(i,
justifyRight(3)(" ")(i) & ": " & (
Line 2,011:
)(
SEQUENCE(16, 6, 32, 1)
)</
and also assuming the following generic binding in the Name Manager for the WorkBook:
<
=LAMBDA(n,
LAMBDA(c,
Line 2,033:
)
)
)</
{{Out}}
Line 2,211:
Or, separating code and character into adjacent Excel cells:
<
=LAMBDA(i,
IF(0 <> MOD(i, 1),
Line 2,229:
)(
SEQUENCE(16, 12, 32, 0.5)
)</
{{Out}}
Line 2,513:
===Idiomatic version===
{{Works with|Factor|0.98}}
<
pair-rocket sequences ;
IN: rosetta-code.ascii-table
Line 2,527:
: print-ascii-table ( -- ) 16 <iota> [ print-row ] each ;
MAIN: print-ascii-table</
===Go translation===
{{Trans|Go}}
{{Works with|Factor|0.98}}
<
pair-rocket sequences ;
IN: rosetta-code.ascii-table
Line 2,549:
;
MAIN: main</
{{out}}
<pre> 32 : Spc 48 : 0 64 : @ 80 : P 96 : ` 112 : p
Line 2,570:
=={{header|Forth}}==
Idiomatic Forth version is factored differently than conventional languages, allowing each factor to be tested independently at the console, bottom up.
<
: ###: ( c -- ) 3 .R ." : " ;
Line 2,586:
: ASCII.TABLE ( -- )
16 0 DO 113 I + 32 I + .ROW LOOP ;</
Test Output at the console
<
32: spc 48: 0 64: @ 80: P 96: ` 112: p
33: ! 49: 1 65: A 81: Q 97: a 113: q
Line 2,606:
46: . 62: > 78: N 94: ^ 110: n 126: ~
47: / 63: ? 79: O 95: _ 111: o 127: del ok
</syntaxhighlight>
Line 2,614:
The dollar sign $ in the format string isn't part of the standard but is a common extension.
ACHAR may not be part of the standard, either.
<
IMPLICIT NONE
INTEGER I, J
Line 2,638:
END
</syntaxhighlight>
output:
<pre> 32:Spc 48: 0 64: @ 80: P 96: ` 112: p
Line 2,661:
=={{header|FreeBASIC}}==
<
if n=32 then return "Spc"
if n=127 then return "Del"
Line 2,682:
print disp
next r
</syntaxhighlight>
{{out}}
Line 2,706:
=={{header|Free Pascal}}==
<
// (except in ISO-compliant “compiler modes”).
program showAsciiTable(output);
Line 2,767:
end;
end;
end.</
{{out}}
Line 2,789:
=={{header|Frink}}==
<
for i = 33 to 126
a.push["$i " + char[i]]
a.push["127 Delete"]
println[formatTableBoxed[columnize[a,8].transpose[], "left"]]</
{{out}}
<pre>
Line 2,826:
=={{header|FutureBasic}}==
<
include "NSLog.incl"
Line 2,858:
HandleEvents
</syntaxhighlight>
{{output}}
<pre>
Line 2,881:
=={{header|Go}}==
<
import "fmt"
Line 2,899:
fmt.Println()
}
}</
{{out}}
Line 2,922:
=={{header|Groovy}}==
{{trans|Java}}
<
static void main(String[] args) {
for (int i = 32; i <= 127; i++) {
Line 2,936:
}
}
}</
{{out}}
<pre> 32: Spc 33: ! 34: " 35: # 36: $ 37: %
Line 2,956:
=={{header|Haskell}}==
<
import Data.List (transpose)
import Data.List.Split (chunksOf)
Line 2,988:
--------------------------- TEST -------------------------
main :: IO ()
main = putStrLn asciiTable</
{{Out}}
<pre> 32 : Spc 48 : 0 64 : @ 80 : P 96 : ` 112 : p
Line 3,008:
=={{header|IS-BASIC}}==
<
110 FOR R=0 TO 15
120 FOR C=32+R TO 112+R STEP 16
Line 3,014:
140 NEXT
150 PRINT
160 NEXT</
=={{header|J}}==
Line 3,079:
=={{header|Java}}==
<
public class ShowAsciiTable {
Line 3,098:
}
</syntaxhighlight>
{{out}}
<pre>
Line 3,120:
=={{header|JavaScript}}==
<
"use strict";
Line 3,225:
// MAIN ---
return asciiTable();
})();</
{{Out}}
<pre> 32 : Spc 48 : 0 64 : @ 80 : P 96 : ` 112 : p
Line 3,245:
=={{header|Jsish}}==
<
/* Show ASCII table, -showAll true to include control codes */
Line 3,311:
015 SI 031 US 047 / 063 ? 079 O 095 _ 111 o 127 DEL
=!EXPECTEND!=
*/</
{{out}}
<pre>prompt$ jsish -u showASCIITable.jsi
Line 3,340:
The following program generalizes the task to produce a table for wide stretches of Unicode characters, not just 32 .. 127. In addition, the functions for producing both row-wise and column-wise tables are provided and illustrated.
<syntaxhighlight lang="jq">
# Pretty printing
def lpad($len): tostring | ($len - length) as $l | (" " * $l)[:$l] + .;
Line 3,368:
end
| lpad(4) ;
</syntaxhighlight>
===Base Task===
<
def prepare($m;$n):
[range($m; $n) | "\(lpad(7)): \(humanize)" ];
Line 3,379:
# Column-wise with 16 rows would be produced by:
# prepare(32;128) | ttable(16)
</syntaxhighlight>
{{out}}
<pre>
Line 3,401:
===Column-wise table of 128..255===
<syntaxhighlight lang="jq">
# Column-wise representation with 16 rows
(prepare(128;256) | ttable(16))
</syntaxhighlight>
{{out}}
<pre>
Line 3,427:
=={{header|Julia}}==
===Base Task===
<
c= i== 0 ? "NUL" : i== 7 ? "BEL" : i== 8 ? "BKS" : i== 9 ? "TAB" :
i==10 ? "LF " : i==13 ? "CR " : i==27 ? "ESC" : i==155 ? "CSI" : "|$(Char(i))|"
print("$(lpad(i,3)) $(string(i,base=16,pad=2)) $c")
(i&7)==7 ? println() : print(" ")
end</
<pre>
32 20 | | 33 21 |!| 34 22 |"| 35 23 |#| 36 24 |$| 37 25 |%| 38 26 |&| 39 27 |'|
Line 3,451:
{{works with|Julia|1.0}}
<
c= i== 0 ? "NUL" : i== 7 ? "BEL" : i== 8 ? "BKS" : i== 9 ? "TAB" :
i==10 ? "LF " : i==13 ? "CR " : i==27 ? "ESC" : i==155 ? "CSI" : "|$(Char(i))|"
print("$(lpad(i,3)) $(string(i,base=16,pad=2)) $c")
(i&7)==7 ? println() : print(" ")
end</
{{out}}
<pre> 0 00 NUL 1 01 |☺| 2 02 |☻| 3 03 |♥| 4 04 |♦| 5 05 |♣| 6 06 |♠| 7 07 BEL
Line 3,494:
This version draws a more fancy table, positioning the items on the console monitor with ANSI control sequences:
<
print("""
0 1 2 3 4 5 6 7 8 9 A B C D E F
Line 3,518:
6<i<11 || i==155 || i==173 || print("\e[$r;$(c)H$(Char(i))")
end
print("\e[54;1H")</
{{out}}
<pre> 0 1 2 3 4 5 6 7 8 9 A B C D E F
Line 3,573:
A similar output can be produced without ANSI control sequences, just filling up a huge string and printing it. Below is a general Object (struct) and the corresponding methods to draw a table of arbitrary shape in the console. It is the Julia way of OOP. The Table structure holds the relevant data and the constructor. The Base.iterate function extends the general iterate function, and allows using the field names in a function, w/o prefixing them with "<structName>." The function prt() fills up a string with data, formatting spaces and new-lines, and prints it to the console.
<
rn: nrows, rh: height of rows
cn: ncols, cw: width of columns
Line 3,620:
end
println("\n$t\n")
end</
Using these is simple, only provide the data, and prt it.
<
Tbl.CH[1,:] = string.(0:15,base=16) # Column headers
Tbl.RH[:,2] = string.(0:15,base=16) # Row headers
Line 3,628:
Tbl.T[i>>4+1,i&15+1,1:2]=["$i",i∈(0,7,8,9,10,13,27,155) ? "" : "$(Char(i))"]
end
prt(Tbl) # format and print table on console</
=={{header|Kotlin}}==
{{trans|Go}}
<
fun main(args: Array<String>) {
Line 3,646:
println()
}
}</
{{output}}
Line 3,669:
{{trans|Go}}
{{works with|langur|0.6.8}}
<
for .j = 31 + .i ; .j < 128 ; .j += 16 {
val .L = given(.j; 32: "spc"; 127: "del"; cp2s .j)
Line 3,675:
}
writeln()
}</
{{out}}
Line 3,697:
=={{header|Locomotive Basic}}==
<
20 for x=1 to 6
30 for y=1 to 16
Line 3,705:
70 print " ";chr$(n);
80 next
90 next</
{{out}}
Line 3,727:
=={{header|Lua}}==
{{trans|Go}}
<
-- map of character values to desired representation
local chars = setmetatable({[32] = "Spc", [127] = "Del"}, {__index = function(_, k) return string.char(k) end})
Line 3,743:
end
io.write"\n"
end</
{{out}}
Line 3,764:
=={{header|M2000 Interpreter}}==
<syntaxhighlight lang="m2000 interpreter">
Function ProduceAscii$ {
Document Ascii$="\"
Line 3,788:
}
Clipboard ProduceAscii$()
</syntaxhighlight>
{{out}}
<pre>
Line 3,801:
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<
{{out}}
<pre>32: Spc 48: 0 64: @ 80: P 96: ` 112: p
Line 3,822:
=={{header|MiniScript}}==
<
// Note changing the values of startChar and endChar will print
// a flexible table in that range
Line 3,855:
end if
end for
if line then print line // final check for odd incomplete line output</
{{out}}
<pre>
Line 3,878:
=={{header|Nanoquery}}==
{{trans|C}}
<
for i in range(0, 15)
for j in range(32 + i, 127, 16)
Line 3,891:
end
println
end</
{{out}}
Line 3,912:
=={{header|Nim}}==
<
for i in 0..15:
Line 3,921:
else: $chr(j)
write(stdout, fmt"{j:3d} : {k:<6s}")
write(stdout, "\n")</
{{out}}
Line 3,945:
=={{header|Objeck}}==
{{trans|Java}}
<
function : Main(args : String[]) ~ Nil {
for(i := 32; i <= 127 ; i += 1;) {
Line 3,961:
};
}
}</
{{output}}
Line 3,984:
=={{header|OxygenBasic}}==
<syntaxhighlight lang="text">
uses console
int i,j
Line 4,002:
next
pause
</syntaxhighlight>
=={{header|Perl}}==
Output in the same style as Raku.
{{trans|Raku}}
<
binmode STDOUT, ':utf8';
Line 4,026:
}
}
print qq[|}\n];</
=={{header|Phix}}==
{{libheader|Phix/basics}}
<!--<
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
Line 4,038:
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #7060A8;">puts</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">join_by</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ascii</span><span style="color: #0000FF;">,</span><span style="color: #000000;">16</span><span style="color: #0000FF;">,</span><span style="color: #000000;">6</span><span style="color: #0000FF;">),</span><span style="color: #008000;">"\x7F"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"del"</span><span style="color: #0000FF;">))</span>
<!--</
{{out}}
<pre> 32 (#20): 48 (#30): 0 64 (#40): @ 80 (#50): P 96 (#60): ` 112 (#70): p
Line 4,059:
=={{header|PHP}}==
<
echo '+' . str_repeat('----------+', 6), PHP_EOL;
Line 4,074:
echo '|', PHP_EOL;
}
echo '+' . str_repeat('----------+', 6), PHP_EOL;</
{{out}}
Line 4,097:
=={{header|PL/M}}==
<
/* CP/M BDOS SYSTEM CALL */
BDOS: PROCEDURE( FN, ARG ); DECLARE FN BYTE, ARG ADDRESS; GOTO 5; END;
Line 4,126:
IF ( ( C - 31 ) MOD 6 ) = 0 THEN CALL PR$STRING( .( 0DH, 0AH, '$' ) );
END;
EOF</
{{out}}
<pre>
Line 4,148:
=={{header|Prolog}}==
<
forall(between(32, 47, N), row(N)).
Line 4,163:
ascii(32) :- write(' Spc '), !.
ascii(127) :- write(' Del '), !.
ascii(A) :- char_code(D,A), format(' ~w ', D).</
{{out}}
<pre>
Line 4,189:
=={{header|PureBasic}}==
<
Define r.i, c.i
For r=0 To 15
Line 4,207:
Next
Input()
EndIf</
{{out}}
<pre> 32 : Spc 48 : 0 64 : @ 80 : P 96 : ` 112 : p
Line 4,229:
===Imperative===
{{trans|Go}}
<
for i in range(16):
for j in range(32+i, 127+1, 16):
Line 4,240:
print("%3d : %-3s" % (j,k), end="")
print()
</syntaxhighlight>
{{Out}}
<pre> 32 : Spc 48 : 0 64 : @ 80 : P 96 : ` 112 : p
Line 4,261:
===HTML===
After Raku, but creating an HTML table:
<
from html import escape
Line 4,276:
print(" </tr><tr>")
print(f' <td style="center">{n}<br>0x{n:02x}<br><big><b title="{escape(name(pp(n)))}">{escape(pp(n))}</b></big></td>')
print(""" </tr>\n</table>""")</
{{out}}
Line 4,422:
Composed from generic abstractions:
<
from functools import reduce
Line 4,529:
# MAIN ---
if __name__ == '__main__':
main()</
{{Out}}
<pre> 32 : Spc 48 : 0 64 : @ 80 : P 96 : ` 112 : p
Line 4,549:
===List Comprehensions===
<
# One-liner
# print('\n'.join([''.join(["%3d : %-3s" % (a, 'Spc' if a == 32 else 'Del' if a == 127 else chr(a)) for a in lst]) for lst in [[i+c*16 for c in range(6)] for i in range(32, 47+1)]])
Line 4,565:
# Joining columns into rows and printing rows one in a separate line
print('\n'.join([''.join(row) for row in rows_as_strings]))</
{{Out}}
<pre> 32 : Spc 48 : 0 64 : @ 80 : P 96 : ` 112 : p
Line 4,585:
=={{header|QB64}}==
<
FOR i% = 32 TO 47
Line 4,600:
NEXT j%
PRINT
NEXT i%</
{{out}}
<pre>
Line 4,622:
=={{header|Quackery}}==
<
[ dup 32 = iff
[ drop say 'spc' ] done
Line 4,640:
echotable
</syntaxhighlight>
{{out}}
<pre>
Line 4,662:
=={{header|R}}==
<
rawToChar(as.raw(n))
}
Line 4,678:
idx <- idx + 6
cat("\n")
}</
{{out}}
<pre> 32 : Spc 33 : ! 34 : " 35 : # 36 : $ 37 : %
Line 4,699:
=={{header|Racket}}==
<
(for ([i (in-range 16)])
Line 4,710:
[127 "DEL"]
[_ (integer->char n)]) #:min-width 5)))
(newline))</
{{out}}
Line 4,735:
Alternately, and perhaps more usefully, output as a wiki-table rather than ASCII art. Hover mouse over the glyph to get the name.
<syntaxhighlight lang="raku"
when * < 33 { (0x2400 + $_).chr } # display symbol names for invisible glyphs
when 127 { '␡' }
Line 4,750:
}
say '|}';</
{{out}}
{|class="wikitable" style="text-align:center;background-color:hsl(39, 90%, 95%)"
Line 4,892:
=={{header|Red}}==
<
repeat i 16 [
Line 4,904:
]
prin newline
]</
{{out}}
<pre>
Line 4,940:
:::* the suppression of displaying particular glyphs by REXX that are preempted by the OS.
:::* adding homage to the adage of: ''anything worth doing is worth doing well''.
<
parse upper version !ver . /*some REXXes can't display '1b'x glyph*/
!pcRexx= 'REXX/PERSONAL'==!ver | "REXX/PC"==!ver /*is this PC/REXX or REXX/Personal? */
Line 4,981:
/*──────────────────────────────────────────────────────────────────────────────────────*/
xhdr: say; _= hdr; sep= b; do k=0 for 16; _=_||b d2x(k)b; end; say _; say; return
grid: arg $1,$2,$3,$4; _=hdr; do 16; _=_ || $1 || $4; $1= $2; end; say _ || $3; return</
{{out|output|text= showing a ''horizontal'' formatted grid (table):}}
Line 5,036:
=={{header|Ring}}==
<
# Project : Show Ascii table
Line 5,083:
}
exec()
}</
Output:
Line 5,089:
=={{header|Ruby}}==
<
k = case ord
when 32 then "␠"
Line 5,098:
end
chars.each_slice(chars.size/6).to_a.transpose.each{|s| puts s.join(" ")}</
{{out}}
<pre>32 : ␠ 48 : 0 64 : @ 80 : P 96 : ` 112: p
Line 5,120:
=={{header|Rust}}==
{{trans|Go}}
<
for i in 0u8..16 {
for j in ((32+i)..128).step_by(16) {
Line 5,132:
println!();
}
}</
{{out}}
Line 5,155:
{{Out}}Best seen in running your browser either by [https://scalafiddle.io/sf/ouiyD9x/0 ScalaFiddle (your local ES aka JavaScript execution, non JVM)] or [https://scastie.scala-lang.org/OD7rBCSMQgKSyKKcGB24cg Scastie (remote JVM)].
{{works with|Scala|2.13}}
<
val (strtCharVal, lastCharVal, nColumns) = (' '.toByte, '\u007F'.toByte, 6)
require(nColumns % 2 == 0, "Number of columns must be even.")
Line 5,179:
.map(_.map(byte => f"$byte%3d : ${k(byte)}"))
.foreach(line => println(line.mkString(" ")))
}</
=={{header|Seed7}}==
<
const proc: main is func
Line 5,202:
writeln;
end for;
end func;</
{{out}}
Line 5,227:
{{works with|HomeSpun}}
{{works with|OpenSpin}}
<
_clkmode = xtal1+pll16x
_clkfreq = 80_000_000
Line 5,256:
waitcnt(_clkfreq + cnt)
ser.stop</
{{out}}
<pre> 32: SPC 48: 0 64: @ 80: P 96: ` 112: p
Line 5,276:
=={{header|Standard ML}}==
<syntaxhighlight lang="text">fun Table n 127 = " 127: 'DEL'\n"
| Table 0 x = "\n" ^ (Table 10 x)
| Table n x = (StringCvt.padLeft #" " 4 (Int.toString x)) ^ ": '" ^ (str (chr x)) ^ "' " ^ ( Table (n-1) (x+1)) ;
print (Table 10 32) ;</
32: ' ' 33: '!' 34: '"' 35: '#' 36: '$' 37: '%' 38: '&' 39: ''' 40: '(' 41: ')'
42: '*' 43: '+' 44: ',' 45: '-' 46: '.' 47: '/' 48: '0' 49: '1' 50: '2' 51: '3'
Line 5,294:
=={{header|Tcl}}==
{{trans|AWK}}
<syntaxhighlight lang="tcl">
for {set i 0} {$i < 16} {incr i} {
for {set j $i} {$j < 128} {incr j 16} {
Line 5,306:
puts ""
}
</syntaxhighlight>
{{out}}
<pre>
Line 5,328:
=={{header|VBA}}==
<syntaxhighlight lang="vb">
Public Sub ascii()
Dim s As String, i As Integer, j As Integer
Line 5,342:
Debug.Print vbCrLf
Next i
End Sub</
{{out}}
<pre> 32: Spc 48: 0 64: @ 80: P 96: ` 112: p
Line 5,364:
=={{header|Visual Basic .NET}}==
{{trans|C#}}
<
Imports System.Linq.Enumerable
Line 5,377:
Loop While start + 16 * 5 < 128
End Sub
End Module</
{{out}}
<pre>32 : Sp 48 : 0 64 : @ 80 : P 96 : ` 112 : p
Line 5,398:
=={{header|Vlang}}==
{{trans|go}}
<
for i in 0..16{
for j := 32 + i; j < 128; j += 16 {
Line 5,415:
println('')
}
}</
{{out}}
Line 5,439:
{{trans|Go}}
{{libheader|Wren-fmt}}
<
for (i in 0...16) {
Line 5,454:
}
System.print()
}</
{{out}}
Line 5,477:
=={{header|XPL0}}==
<
[SetHexDigits(2);
Text(0, " ");
Line 5,489:
CrLf(0);
];
]</
{{out}}
Line 5,513:
=={{header|zkl}}==
<
println(" ",[0..width].pump(String,"%4d".fmt));
[30..127].pump("".println,T(Void.Read,width,False), // don't fail on short lines
Line 5,522:
T("replace"," ","spc"),T("replace","\x7f","del"), "%-4s".fmt)
)
})</
{{out}}
<pre> 0 1 2 3 4 5 6 7 8 9
Line 5,538:
=={{header|ZX Spectrum Basic}}==
Note in particular entries 94, 96 and 127.
<
20 PRINT AT 0,4+2*x;x
30 PRINT AT x+1,0;10*(3+x)
Line 5,546:
70 LET t=(x-d)/10
80 PRINT AT t-2,4+2*d;CHR$ x
90 NEXT x</
{{out}}
|