Character codes: Difference between revisions

m
Added Plain English
m (→‎{{header|Wren}}: Changed to Wren S/H)
m (Added Plain English)
 
(10 intermediate revisions by 7 users not shown)
Line 493:
babel
=={{header|BASIC}}==
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
<syntaxhighlight lang="qbasic">charCode = 97
Line 527 ⟶ 528:
$: 36
€: 8364, 36</pre>
 
==={{header|Chipmunk Basic}}===
<syntaxhighlight lang="qbasic">10 print "a - > ";asc("a")
20 print "98 -> ";chr$(98)</syntaxhighlight>
 
==={{header|Commodore BASIC}}===
Line 536 ⟶ 541:
{{Out}}<pre>A
66</pre>
 
==={{header|GW-BASIC}}===
{{works with|PC-BASIC|any}}
{{works with|BASICA}}
<syntaxhighlight lang="qbasic">10 PRINT "a - > "; ASC("a")
20 PRINT "98 -> "; CHR$(98)</syntaxhighlight>
 
==={{header|IS-BASIC}}===
<syntaxhighlight lang="is-basic">100 PRINT ORD("A")
110 PRINT CHR$(65)</syntaxhighlight>
 
==={{header|MSX Basic}}===
{{works with|MSX BASIC|any}}
<syntaxhighlight lang="qbasic">10 PRINT "a - > "; ASC("a")
20 PRINT "98 -> "; CHR$(98)</syntaxhighlight>
 
==={{header|QBasic}}===
{{works with|BASICA}}
{{works with|Chipmunk Basic}}
{{works with|FreeBASIC}}
{{works with|GW-BASIC}}
{{works with|MSX BASIC}}
{{works with|PC-BASIC}}
{{works with|Run BASIC}}
{{works with|Yabasic}}
<syntaxhighlight lang="qbasic">PRINT "a - > "; ASC("a")
PRINT "98 -> "; CHR$(98)</syntaxhighlight>
Line 566 ⟶ 588:
PRINT "98 -> "; chr$(98)
END</syntaxhighlight>
 
==={{header|XBasic}}===
{{works with|Windows XBasic}}
{{works with|Linux XBasic}}
<syntaxhighlight lang="qbasic">PROGRAM "Character codes"
VERSION "0.0000"
 
DECLARE FUNCTION Entry ()
 
FUNCTION Entry ()
PRINT "a - >"; ASC("a")
PRINT "98 -> "; CHR$(98)
END FUNCTION
END PROGRAM</syntaxhighlight>
 
==={{header|Yabasic}}===
Line 912 ⟶ 948:
Limitations: There is no "put_character_32" feature for standard io (FILE class), so there appears to be no way to print Unicode characters.
=={{header|Elena}}==
ELENA 46.x :
<syntaxhighlight lang="elena">import extensions;
 
Line 919 ⟶ 955:
var ch := $97;
 
console.printLine:(ch);
console.printLine(ch.toInt())
}</syntaxhighlight>
Line 927 ⟶ 963:
97
</pre>
 
=={{header|Elixir}}==
A String in Elixir is a UTF-8 encoded binary.
Line 1,009 ⟶ 1,046:
fansh> 'a'.toInt
97</syntaxhighlight>
 
=={{header|Fennel}}==
<syntaxhighlight lang="fennel">
(string.byte :A) ; 65
(string.char 65) ; "A"
</syntaxhighlight>
 
=={{header|Forth}}==
As with C, characters are just integers on the stack which are treated as ASCII.
Line 1,348 ⟶ 1,392:
Langur has code point literals (enclosed in straight single quotes), which may use escape codes. They are integers.
 
The s2cp(), cp2s(), and cp2ss2gc() functions convert between code point integers, grapheme clusters and strings. Also, string indexing is by code point.
 
<syntaxhighlight lang="langur">val .a1 = 'a'
Line 1,360 ⟶ 1,404:
writeln .a3 == .a4
writeln "numbers: ", join ", ", [.a1, .a2, .a3, .a4, .a5]
writeln "letters: ", join ", ", map cp2s, [cp2s(.a1), cp2s(.a2), cp2s(.a3), cp2s(.a4), cp2s(.a5)]</syntaxhighlight>
 
{{out}}
Line 1,369 ⟶ 1,413:
letters: a, a, a, a, aaaa
</pre>
 
=={{header|Lasso}}==
<syntaxhighlight lang="lasso">'a'->integer
Line 1,541 ⟶ 1,586:
The character for '65' is: A.
Press any key to continue...</syntaxhighlight>
=={{header|MiniScript}}==
{{trans|Wren}}
MiniScript does not have a ''character'' type as such but one can use single character strings instead. Strings can contain any Unicode code point.
<syntaxhighlight lang="miniscript">cps = []
for c in ["a", "π", "字", "🐘"]
cp = c.code
cps.push cp
print c + " = " + cp
end for
print
for i in cps
print i + " = " + char(i)
end for</syntaxhighlight>
 
{{out}}
<pre>a = 97
π = 960
字 = 23383
🐘 = 128024
 
97 = a
960 = π
23383 = 字
128024 = 🐘
</pre>
 
=={{header|Modula-2}}==
<syntaxhighlight lang="modula2">MODULE asc;
Line 1,563 ⟶ 1,634:
<syntaxhighlight lang="modula-2">jan@Beryllium:~/modula/rosetta$ ./asc
a 97 1</syntaxhighlight>
 
=={{header|Modula-3}}==
The built in functions <code>ORD</code> and <code>VAL</code> work on characters, among other things.
Line 1,765 ⟶ 1,837:
<syntaxhighlight lang="pascal">writeln(ord('a'));
writeln(chr(97));</syntaxhighlight>
=={{header|Plain English}}==
<syntaxhighlight>
\ Obs: The little-a byte is a byte equal to 97.
Write the little-a byte's whereabouts on the console.
Put 97 into a number.
Write the number's target on the console.
</syntaxhighlight>
=={{header|Perl}}==
===Narrow===
Line 2,649 ⟶ 2,728:
test = (chr97,asc`a)</syntaxhighlight>
{{Out}}<pre>(`a,97)</pre>
 
=={{header|Uxntal}}==
<syntaxhighlight lang="Uxntal">
( uxnasm char-codes.tal char-codes.rom && uxncli char-codes.rom )
 
|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
 
|0100
[ LIT "a ] print-hex
newline
#61 .Console/write DEO
newline
 
( exit )
#80 .System/state DEO
BRK
 
@print-hex
DUP #04 SFT print-digit #0f AND print-digit
JMP2r
 
@print-digit
DUP #09 GTH #27 MUL ADD #30 ADD .Console/write DEO
JMP2r
 
@newline
#0a .Console/write DEO
JMP2r</syntaxhighlight>
 
Output:
<pre>61
a</pre>
 
=={{header|VBA}}==
<syntaxhighlight lang="vba">Debug.Print Chr(97) 'Prints a
18

edits