不同 Unicode 规范化形式的最大字符更改数是多少?

What is the maximum number of character changes for different Unicode normalization form?

使用不同的 Unicode 规范化形式可能会导致相同输入的输出长度不同。例如:

>>> import unicodedata
>>> c = "å"
>>> a = len(unicodedata.normalize("NFC", c))
>>> b = len(unicodedata.normalize("NFKD", c))
>>> print(a, b)
1 2

当你改变c时,b/a的最大值是多少?

截至撰写本文时(Unicode 13.0),字符的 NFC 和 NFKD 扩展之间的最大长度差异是 18 的因数。 U+FDFA ﷺ ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM 不受归一化形式C和D的影响,但在KC和KD下分解为18个码位的序列(ain)。

但是,标准中对此没有正式定义的限制。未来的更新理论上可以添加一个具有更长分解映射的新角色。 Unicode 标准仅保证 NFC 的上限。每 Unicode Stability Policy:

Canonical mappings (Decomposition_Mapping property values) are always limited so that no string when normalized to NFC expands to more than 3× in length (measured in code units).