How do character length and UTF-8 byte length differ for a label?

length counts Unicode code points in text and bytes in a BLOB. A displayed grapheme can contain multiple code points.

SQLite example and interpretation

In a UTF-8 database the label 云A occupies two code points and four bytes. Measure encoded bytes when enforcing a payload limit.

SELECT length('云A'),length(CAST('云A' AS BLOB));

Result [[2, 4]]

中文

中文标签的字符数和 UTF-8 字节数怎样区分?

length 对文本计 Unicode 码点,对 BLOB 计字节。码点数也可能不同于人眼感知的字符数。

SQLite 示例与适用条件

UTF-8 数据库里“云A”是两个码点、四个字节。限制网络载荷时应计编码后的字节。

SELECT length('云A'),length(CAST('云A' AS BLOB));

结果 [[2, 4]]

References / 参考来源

Keep reading / 继续阅读