> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# unhex

> 将十六进制字符串转换为其对应的二进制字符串；hex 函数的反向函数。

将输入的参数 `str` 中的两个字符为一组转化为16进制后的字符，然后拼接成字符串输出。

## 语法

```Haskell theme={null}
UNHEX(str);
```

## 参数说明

`str`: 支持的数据类型为 VARCHAR，长度为0或为奇数，或者包含`[0-9]`、`[a-z]`、`[A-Z]`之外的字符则返回空串。

## 返回值说明

返回值的数据类型为 VARCHAR。

## 示例

```Plain Text theme={null}
mysql> select unhex('3132');
+---------------+
| unhex('3132') |
+---------------+
| 12            |
+---------------+
1 row in set (0.00 sec)

mysql> select unhex('4142@');
+----------------+
| unhex('4142@') |
+----------------+
|                |
+----------------+
1 row in set (0.01 sec)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.