Character codes: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 930: | Line 930: | ||
<syntaxhighlight lang="lisp">(string-to-char "a") ;=> 97 |
<syntaxhighlight lang="lisp">(string-to-char "a") ;=> 97 |
||
(format "%c" 97) ;=> "a"</syntaxhighlight> |
(format "%c" 97) ;=> "a"</syntaxhighlight> |
||
=={{header|EMal}}== |
|||
<syntaxhighlight lang="emal"> |
|||
^|ord and chr work with Unicode code points|^ |
|||
writeLine(ord("a")) # prints "97" |
|||
writeLine(chr(97)) # prints "a" |
|||
writeLine(ord("π")) # prints "960" |
|||
writeLine(chr(960)) # prints "π" |
|||
writeLine() |
|||
var cps = int[] |
|||
for each var c in text["a", "π", "字", "🐘"] |
|||
var cp = ord(c) |
|||
cps.append(cp) |
|||
writeLine(c + " = " + cp) |
|||
end |
|||
writeLine() |
|||
for each int i in cps |
|||
var c = chr(i) |
|||
writeLine(i + " = " + c) |
|||
end |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
97 |
|||
a |
|||
960 |
|||
π |
|||
a = 97 |
|||
π = 960 |
|||
字 = 23383 |
|||
🐘 = 128024 |
|||
97 = a |
|||
960 = π |
|||
23383 = 字 |
|||
128024 = 🐘 |
|||
</pre> |
|||
=={{header|Erlang}}== |
=={{header|Erlang}}== |
||
In Erlang, lists and strings are the same, only the representation changes. Thus: |
In Erlang, lists and strings are the same, only the representation changes. Thus: |