UTF-8 encode and decode: Difference between revisions

Content added Content deleted
Line 302: Line 302:
€ 20AC [E2, 82, AC]
€ 20AC [E2, 82, AC]
𝄞 1D11E [F0, 9D, 84, 9E]</pre>
𝄞 1D11E [F0, 9D, 84, 9E]</pre>
=={{header|Elena}}==
ELENA 3.3 :
<lang elena>import system'routines.
import extensions.

literal extension op
{
literal printAsString
[
console print(self," ")
]

literal printAsUTF8Array
[
self toByteArray; forEach(:b) [ console print(b toLiteral(16)," ") ].
]
printAsUTF32
[
self toArray; forEach(:c)[ console print("U+",c toInt; toLiteral(16)," ") ].
]
}

program =
[
"A" printAsString; printAsUTF8Array; printAsUTF32.
console printLine.
"ö" printAsString; printAsUTF8Array; printAsUTF32.
console printLine.

"Ж" printAsString; printAsUTF8Array; printAsUTF32.
console printLine.

"€" printAsString; printAsUTF8Array; printAsUTF32.
console printLine.

"𝄞" printAsString; printAsUTF8Array; printAsUTF32.
console printLine.
].</lang>
{{out}}
<pre>
A 41 U+41
ö C3 B6 U+F6
Ж D0 96 U+416
€ E2 82 AC U+20AC
𝄞 F0 9D 84 9E U+1D11E</pre>


=={{header|Go}}==
=={{header|Go}}==