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);