UTF-8 encode and decode: Difference between revisions
Added 11l
(→C#) |
Alextretyak (talk | contribs) (Added 11l) |
||
Line 20:
Provided below is a reference implementation in Common Lisp.
=={{header|11l}}==
{{trans|Python}}
<lang 11l>F unicode_code(ch)
R ‘U+’hex(ch.code).zfill(4)
F utf8hex(ch)
R ch.encode(‘utf-8’).map(c -> hex(c)).join(‘ ’)
print(‘#<11 #<15 #<15’.format(‘Character’, ‘Unicode’, ‘UTF-8 encoding (hex)’))
V chars = [‘A’, ‘ö’, ‘Ж’, ‘€’]
L(char) chars
print(‘#<11 #<15 #<15’.format(char, unicode_code(char), utf8hex(char)))</lang>
{{out}}
<pre>
Character Unicode UTF-8 encoding (hex)
A U+0041 41
ö U+00F6 C3 B6
Ж U+0416 D0 96
€ U+20AC E2 82 AC
</pre>
=={{header|8th}}==
|