unistr() 是一个用于解码带有Unicode转义序列的字符串的系统函数。
unistr() 函数已添加到 PostgreSQL 14 版本中。
示例
unistr() 的基本用法
postgres=# SELECT unistr('\307B\3052');
unistr
--------
ほげ
(1 row)
具有无效Unicode码点的执行
postgres=# SELECT unistr('\0000');
ERROR: invalid Unicode code point: 0000
无效Unicode转义的执行
postgres=# SELECT unistr('\+10000');
ERROR: invalid Unicode escape
HINT: Unicode escapes must be \XXXX, \+XXXXXX, \uXXXX, or \UXXXXXXXX.
参考资料
- PostgreSQL 文档: 其他字符串函数
有用链接
- 等待PostgreSQL 14 – 添加unistr函数 - depesz 的 2021 年 4 月博客文章
