perldoc > Unicode::Normalize

📛 NAME

Unicode::Normalize - Unicode Normalization Forms

🚀 Quick Reference

Use CaseCommandDescription
Canonical DecompositionNFD($string)Normalize to Form D
Canonical CompositionNFC($string)Normalize to Form C
Compatibility DecompositionNFKD($string)Normalize to Form KD
Compatibility CompositionNFKC($string)Normalize to Form KC
Check NormalizationcheckNFC($string)Returns YES/NO/MAYBE
Partial Normalizationnormalize_partial($form, $unproc)Normalize incrementally

📖 SYNOPSIS

(1) using function names exported by default:

  use Unicode::Normalize;

  $NFD_string  = NFD($string);  # Normalization Form D
  $NFC_string  = NFC($string);  # Normalization Form C
  $NFKD_string = NFKD($string); # Normalization Form KD
  $NFKC_string = NFKC($string); # Normalization Form KC

(2) using function names exported on request:

  use Unicode::Normalize 'normalize';

  $NFD_string  = normalize('D',  $string);  # Normalization Form D
  $NFC_string  = normalize('C',  $string);  # Normalization Form C
  $NFKD_string = normalize('KD', $string);  # Normalization Form KD
  $NFKC_string = normalize('KC', $string);  # Normalization Form KC

📝 DESCRIPTION

Parameters:

Note: Between XSUB and pure Perl, there is an incompatibility about the interpretation of $code_point as a decimal number. XSUB converts $code_point to an unsigned integer, but pure Perl does not. Do not use a floating point nor a negative sign in $code_point.

🔄 Normalization Forms

⚙️ Decomposition and Composition

 $NFD_string  = reorder(decompose($string));       # eq. to NFD()
 $NFKD_string = reorder(decompose($string, TRUE)); # eq. to NFKD()
 $concat_NFD  = reorder(join '', @NFD_strings);
 $concat_NFKD = reorder(join '', @NFKD_strings);
 $NFC_string  = compose($NFD_string);
 $NFKC_string = compose($NFKD_string);
 # Wrong: $concat = $normalized . normalize($form, $unnormalized);
 # Correct:
 ($processed, $unprocessed) = splitOnLastStarter($normalized);
 $concat = $processed . normalize($form,$unprocessed.$unnormalized);
 # Incremental normalization of array:
 my $result = "";
 my $unproc = "";
 foreach my $str (@string) {
     $unproc .= $str;
     my $n = normalize($form, $unproc);
     my($p, $u) = splitOnLastStarter($n);
     $result .= $p;
     $unproc  = $u;
 }
 $result .= $unproc;
 my $result = "";
 my $unproc = "";
 foreach my $str (@string) {
     $unproc .= $str;
     $result .= normalize_partial($form, $unproc);
 }
 $result .= $unproc;

✅ Quick Check

(see Annex 8, UAX #15; and DerivedNormalizationProps.txt)

The following functions check whether the string is in that normalization form. The result is one of:
YES — The string is in that normalization form.
NO — The string is not in that normalization form.
MAYBE — Dubious.

Note: In NFD, NFKD, FCD, answer is always YES or NO. In NFC, NFKC, FCC, MAYBE may be returned. A MAYBE string contains at least one combining character. For example, "A\N{COMBINING ACUTE ACCENT}" returns MAYBE with checkNFC. To check exactly, compare with NFC:

if ($string eq NFC($string)) {
    # $string is exactly normalized in NFC;
} else {
    # $string is not normalized in NFC;
}

📊 Character Data

These functions are interface of character data used internally. You don't need to call them for normalization.

📦 EXPORT

NFC, NFD, NFKC, NFKD: by default.
normalize and other some functions: on request.

⚠️ CAVEATS

Perl's version vs. Unicode version

This module refers to perl core's Unicode database. The Unicode version of normalization depends on what has been compiled into your perl. The following table lists the default Unicode version that comes with various perl versions.

Perl versionUnicode version
5.6.13.0.1
5.7.23.1.0
5.7.33.1.1 (normalization same as 3.1.0)
5.8.03.2.0
5.8.1-5.8.34.0.0
5.8.4-5.8.64.0.1 (normalization same as 4.0.0)
5.8.7-5.8.84.1.0
5.10.05.0.0
5.8.9, 5.10.15.1.0
5.12.x5.2.0
5.14.x6.0.0
5.16.x6.1.0
5.18.x6.2.0
5.20.x6.3.0
5.22.x7.0.0

Correction of decomposition mapping

In older Unicode versions, a small number of characters (CJK compatibility ideographs) may have erroneous decomposition mappings. This module does not refer to NormalizationCorrections.txt, so it may use erroneous mappings on older perl.

Revised definition of canonical composition

In Unicode 4.1.0, the definition D2 of canonical composition (affecting NFC and NFKC) has been changed. This module has used the newer definition since version 0.07 (Oct 31, 2001). It will not support the older definition.

👤 AUTHOR

SADAHIRO Tomoyuki <SADAHIRO AT cpan.org>

Currently maintained by <perl5-porters AT perl.org>

Copyright(C) 2001-2012, SADAHIRO Tomoyuki. Japan. All rights reserved.

📜 LICENSE

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

🔗 SEE ALSO

Unicode::Normalize
📛 NAME 🚀 Quick Reference 📖 SYNOPSIS 📝 DESCRIPTION
🔄 Normalization Forms ⚙️ Decomposition and Composition ✅ Quick Check 📊 Character Data
📦 EXPORT ⚠️ CAVEATS
Perl's version vs. Unicode version Correction of decomposition mapping Revised definition of canonical composition
👤 AUTHOR 📜 LICENSE 🔗 SEE ALSO

Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-31 10:41 @216.73.217.152
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^