Character codes: Difference between revisions
Content added Content deleted
(Added ZX81 BASIC) |
(+Stata) |
||
Line 1,625: | Line 1,625: | ||
<lang sml>print (Int.toString (ord #"a") ^ "\n"); (* prints "97" *) |
<lang sml>print (Int.toString (ord #"a") ^ "\n"); (* prints "97" *) |
||
print (Char.toString (chr 97) ^ "\n"); (* prints "a" *)</lang> |
print (Char.toString (chr 97) ^ "\n"); (* prints "a" *)</lang> |
||
=={{header|Stata}}== |
|||
The Mata '''ascii''' function transforms a string in a numeric vector of UTF-8 bytes. For instance: |
|||
<lang stata>: ascii("α") |
|||
1 2 |
|||
+-------------+ |
|||
1 | 206 177 | |
|||
+-------------+</lang> |
|||
Where 206, 177 is the UTF-8 encoding of Unicode character 945 (GREEK SMALL LETTER ALPHA). |
|||
ASCII characters are mapped to single bytes: |
|||
<lang stata>: ascii("We the People") |
|||
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|||
+-------------------------------------------------------------------------------+ |
|||
1 | 87 101 32 116 104 101 32 80 101 111 112 108 101 | |
|||
+-------------------------------------------------------------------------------+</lang> |
|||
=={{header|Swift}}== |
=={{header|Swift}}== |