unicode_assigned()

一个确定字符串是否仅包含Unicode码位的函数

unicode_assigned() 是一个系统函数,用于确定字符串中的所有字符是否都是已分配的Unicode码位。

unicode_assigned() 已在 PostgreSQL 17 中添加。

用法

unicode_assigned ( text ) → boolean

unicode_assigned() 只能在数据库编码为 UTF8 时使用。

变更历史

示例

unicode_assigned() 的基本用法示例

postgres=# SELECT unicode_assigned(U&'abcほげ');
 unicode_assigned 
------------------
 t
(1 row)

包含一个未分配给Unicode字符的码位的字符串

postgres=# SELECT unicode_assigned(U&'abcほげ\+10FFFF');
 unicode_assigned 
------------------
 f
(1 row)

在非UTF8数据库中尝试使用 unicode_assigned()

postgres=# CREATE DATABASE iso8859 TEMPLATE template0 ENCODING 'iso-8859-1' LOCALE 'C';
CREATE DATABASE

postgres=# \c iso8859 
You are now connected to database "iso8859" as user "postgres".

iso8859=# SELECT unicode_assigned('abc');
ERROR:  Unicode categorization can only be performed if server encoding is UTF8

分类

排序规则, 区域设置和字符集处理

另请参阅

unistr()

反馈

提交关于“unicode_assigned()”的任何评论、建议或更正,请在此处 提交