postgreSQL length 函数如何处理 unicode 字素



考虑以下情况,其中我的字符串U00000045U00000301定义。

1( https://www.fileformat.info/info/unicode/char/0045/index.htm
2( https://www.fileformat.info/info/unicode/char/0301/index.htm

varchar(1)约束的表是否会将其视为有效的 1 个字符输入。还是会因为它被视为 2 个字符的输入而被拒绝?

SQL 通常如何处理包含字素的字符串的长度?

我可能看起来很愚蠢这个查询,但仍然:

t=# with c(u) as (values( e'U00000045U00000301'))
select u, u::varchar(1), u::varchar(2),char_length(u), octet_length(u) from c;
 u | u | u | char_length | octet_length
---+---+---+-------------+--------------
 É | E | É |           2 |            3
(1 row)

编辑

t=# show server_encoding ;
 server_encoding
-----------------
 UTF8
(1 row)
t=# l+ t
                                        List of databases
 Name | Owner | Encoding | Collate | Ctype | Access privileges | Size  | Tablespace | Description
------+-------+----------+---------+-------+-------------------+-------+------------+-------------
 t    | vao   | UTF8     | C       | UTF-8 |                   | 51 MB | pg_default |
(1 row)

最新更新