跳到主要内容
uencoder

Unicode Normalization Reference

Reference 为 Unicode normalization forms: NFC, NFD, NFKC, NFKD 和其 用例.

Normalization Forms

NFC (Canonical Composition) composes characters and decomposes then recomposes, producing the shortest composed form. NFD (Canonical Decomposition) decomposes all composable characters. NFKC (Compatibility Composition) additionally maps compatibility characters (e.g., fullwidth to ASCII). NFKD (Compatibility Decomposition) decomposes compatibility characters. NFC is the recommended default for storage and interchange. W3C recommends NFC for web content.

NFC
Composed, recommended
W3C default
NFD
Decomposed
for processing
NFKC/NFKD
Compatibility mapping
fullwidth -> ASCII

Practical Considerations

Normalization affects string comparison: visually identical strings may differ in code points without normalization. Database storage should normalize to NFC for consistent comparison and indexing. Search should normalize both query and indexed text. Normalization can change string length (composition shortens, decomposition lengthens). Some languages (e.g., Korean Hangul) have complex composition rules. The choice of form depends on the use case: NFC for storage, NFKC for fuzzy search. Always normalize before comparison.

comparison
Normalize first
visual = code point
storage
NFC recommended
consistent indexing
search
NFKC for fuzzy
compatibility match

相关工具

参考链接