UNHEX
Descriptionβ
The unhex
function is used to convert a hexadecimal string back into the original string. It converts every two hexadecimal characters into one byte.
Syntaxβ
UNHEX(<str>)
Parametersβ
Parameter | Description |
---|---|
<str> | The hexadecimal character string |
Return Valueβ
If the input string has a length of 0 or is odd, it returns an empty string. If the string contains characters other than [0-9], [a-f], or [A-F], it returns an empty string. In other cases, every two characters are converted to their hexadecimal representation and concatenated into a string for output.
Examplesβ
select unhex('@');
+------------+
| unhex('@') |
+------------+
| |
+------------+
select unhex('41');
+-------------+
| unhex('41') |
+-------------+
| A |
+-------------+
select unhex('4142');
+---------------+
| unhex('4142') |
+---------------+
| AB |
+---------------+