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

20 lines
567 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
$ 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
2024-04-19 16:56:29 -07:00
utf8 := toUtf8(str(ch));
2023-07-01 11:58:00 -04:00
writeln(ch rpad 11 <& "U+" <& ord(ch) radix 16 lpad0 4 rpad 7 <&
2024-04-19 16:56:29 -07:00
hex(utf8) rpad 22 <& fromUtf8(utf8));
2023-07-01 11:58:00 -04:00
end for;
end func;