Encoding Functions

FROM_BASE64

FROM_BASE64(s) Decodes the base64 string s into a bytes value.

 SELECT FROM_BASE64('Zm9v')
'Zm9v'

FROM_HEX

FROM_HEX(s) Decodes the hex string s into a bytes value.

 SELECT FROM_HEX('666f6f')
'Zm9v'
 SELECT FROM_HEX('626172')
'YmFy'

FROM_UTF8

FROM_UTF8(b) If b is a bytes value that represents a valid UTF-8 string, return it as a string. Otherwise, raise an error.

 SELECT FROM_UTF8(bytes 'foo')
'foo'
 SELECT FROM_UTF8(bytes 'bar')
'bar'

TO_BASE64

TO_BASE64(b) Encodes the bytes value b into a base64 string representation.

 SELECT TO_BASE64(bytes 'foo')
'Zm9v'

TO_HEX

TO_HEX(b) Encodes the bytes value b into a hex string representation.

 SELECT TO_HEX(bytes 'foo')
'666f6f'
 SELECT TO_HEX(bytes 'bar')
'626172'

TO_UTF8

TO_UTF8(s) Return the bytes UTF-8 representation of the string value s.

 SELECT TO_UTF8('foo')
'Zm9v'
 SELECT TO_UTF8('bar')
'YmFy'

URL_ENCODE

URL_ENCODE(value) Encodes the string into a percent-encoded ASCII text representation

 SELECT URL_ENCODE('foo bar?')
'foo%20bar%3f'

URL_DECODE

URL_ENCODE(value) Encodes the string into a percent-encoded ASCII text representation

 SELECT URL_DECODE('foo%20bar%3f')
'foo bar?'