HEX_ENCODE()

All functions > STRING > HEX_ENCODE()

Encodes a string as a contiguous hexadecimal string (two hex digits per byte).

Signatures

Returns: Hex digits only (length is even for non-NULL input)

HEX_ENCODE(string: VARCHAR) → VARCHAR
sql
ParameterTypeRequiredDescription
stringVARCHARYesInput text to encode

Notes

  • Each input byte becomes two hexadecimal characters (uppercase AF)
  • Returns NULL if the input is NULL (use NULL(VARCHAR); bare NULL fails inference)
  • Pair with HEX_DECODE to recover the original string when the hex is valid

See also

Examples

FeatureQL
SELECT
    f1 := HEX_ENCODE('hello'), -- UTF-8 bytes of ASCII text
    f2 := HEX_ENCODE(''), -- Empty string
    f3 := HEX_ENCODE(NULL(VARCHAR)) -- NULL yields NULL
;
Result
f1 VARCHARf2 VARCHARf3 VARCHAR
68656C6C6F(empty)NULL

Last update at: 2026/05/26 17:22:09