RosettaCodeData/Task/UTF-8-encode-and-decode/DuckDB/utf-8-encode-and-decode.duckdb

13 lines
341 B
Plaintext

create or replace function utf8x(codepoint) as (
select hex(encode(chr(codepoint)))
);
# Example:
select s,
unicode(s) as codepoint,
chr(codepoint) as c,
unicode(c),
utf8x(codepoint),
decode(from_hex(utf8x(codepoint))) as "decode(from_hex())"
from values ('A'), ('ö'), ('Ж'), ('€'), ('𝄞') t(s);