RosettaCodeData/Task/UTF-8-encode-and-decode/Seed7/utf-8-encode-and-decode.seed7

20 lines
567 B
Plaintext

$ include "seed7_05.s7i";
include "unicode.s7i";
include "console.s7i";
include "bytedata.s7i";
const proc: main is func
local
var char: ch is ' ';
var string: utf8 is "";
begin
OUT := STD_CONSOLE;
writeln("Character Unicode UTF-8 encoding (hex) Decoded");
writeln("-------------------------------------------------");
for ch range "AöЖ€𝄞" do
utf8 := toUtf8(str(ch));
writeln(ch rpad 11 <& "U+" <& ord(ch) radix 16 lpad0 4 rpad 7 <&
hex(utf8) rpad 22 <& fromUtf8(utf8));
end for;
end func;