Character codes: Difference between revisions

PascalABC.NET
No edit summary
(PascalABC.NET)
 
(2 intermediate revisions by 2 users not shown)
Line 1,390:
97 chr . # a</syntaxhighlight>
=={{header|langur}}==
<syntaxhighlight lang="langur">val a1 = 'a'
Langur has code point literals (enclosed in straight single quotes), which may use escape codes. They are integers.
val .a2 = 97
val .a3 = "a"[1]
val .a4 = s2cp ("a", 1)
val .a5 = [.a1, .a2, .a3, .a4]
 
writeln .a1 == .a2
The s2cp(), cp2s(), and s2gc() functions convert between code point integers, grapheme clusters and strings. Also, string indexing is by code point.
writeln .a2 == .a3
writeln .a3 == .a4
writeln "numbers: ", join (", ", map(string, [.a1, .a2, .a3, .a4, .a5]))
writeln "letters: ", join (", ", map (cp2s, [.a1, .a2, .a3, .a4, .a5]</syntaxhighlight>))
 
</syntaxhighlight lang="langur">val .a1 = 'a'
val .a2 = 97
val .a3 = "a"[1]
val .a4 = s2cp "a", 1
val .a5 = [.a1, .a2, .a3, .a4]
 
writeln .a1 == .a2
writeln .a2 == .a3
writeln .a3 == .a4
writeln "numbers: ", join ", ", [.a1, .a2, .a3, .a4, .a5]
writeln "letters: ", join ", ", map cp2s, [.a1, .a2, .a3, .a4, .a5]</syntaxhighlight>
 
{{out}}
Line 1,837 ⟶ 1,835:
<syntaxhighlight lang="pascal">writeln(ord('a'));
writeln(chr(97));</syntaxhighlight>
 
=={{header|PascalABC.NET}}==
<syntaxhighlight lang="delphi">
begin
var c := 'a';
var i := c.Code;
Println(i);
Println(Chr(i))
end.
</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===
222

edits