ASCII control characters: Difference between revisions

Added Wren
(C D perl)
 
(Added Wren)
Line 52:
charnames::string_vianame $_;
</syntaxhighlight>
 
=={{header|Wren}}==
{{libheader|Wren-dynamic}}
I assume this isn't intended to be a task but simply a reference to how individual languages might treat ASCII control characters ''en bloc'' using enum like structures or otherwise. Note that technically 'space' is a printable character, not a control character.
 
Wren doesn't have enums built into the language but can create them dynamically at runtime. However, such enums need to have consecutive integer values.
 
Here, we create instead a ''Group'' which can contain any values in any order.
<syntaxhighlight lang="ecmascript">import "./dynamic" for Group
 
var names = [
"nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel",
"bs", "ht", "lf", "vt", "ff", "cr", "so", "si",
"dle", "dc1", "dc2", "dc3", "dc4", "nak", "syn", "etb",
"can", "em", "sub", "esc", "fs", "gs", "rs", "us",
"space", "del"
]
 
var values = (0..32).toList + [127]
 
var Ctrl = Group.create("Ctrl", names, values)
 
// print some specimen values
System.print(Ctrl.cr)
System.print(Ctrl.del)</syntaxhighlight>
 
{{out}}
<pre>
13
127
</pre>
9,485

edits