->HEX function decodes an hex encoded string or a byte array. For different encodings, use bytes array conversion
Applied on a string,
'utf-8' ->BYTES ->HEX
Since 2.8.0 this function also converts a long to its 64 bits hexadecimal representation. Thus this function is equivalent to TOHEX.
If the encoded content is not a valid UTF-8 representation, the resulting string will reflect that.