Jump to content

UTF-8 encode and decode: Difference between revisions

m
(Add Seed7 example.)
Line 369:
𝄞 1D11E [F0, 9D, 84, 9E]</pre>
=={{header|Elena}}==
ELENA 3.4.x :
<lang elena>import system'routines.;
import extensions.;
extension<literal> op : String
{
literalstring printAsString()
[{
console .print(self," ")
]}
literalstring printAsUTF8Array ()
[{
self .toByteArray; forEach().forEach:(b) [{ console .print(b toLiteral.toString(16)," ") ].}
]}
string printAsUTF32()
[{
self .toArray; forEach().forEach:(c)[{ console .print("U+",c .toInt; toLiteral().toString(16)," ") ].}
]}
}
public program()
{
[
"A" .printAsString; ().printAsUTF8Array; printAsUTF32().printAsUTF32();
console printLine.printLine();
"ö" .printAsString; ().printAsUTF8Array; printAsUTF32().printAsUTF32();
console printLine.printLine();
"Ж" .printAsString; ().printAsUTF8Array; printAsUTF32().printAsUTF32();
console printLine.printLine();
"€" .printAsString; ().printAsUTF8Array; printAsUTF32().printAsUTF32();
console printLine.printLine();
"𝄞" .printAsString; ().printAsUTF8Array; printAsUTF32().printAsUTF32();
console printLine.printLine();
]}</lang>
{{out}}
<pre>
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.