SourcePro : Internationalization Module User’s Guide : Normalization : Using RWUNormalizer : Detecting the Normalization Form of a String
Detecting the Normalization Form of a String
RWUNormalizer provides a CheckResult enum. The static quickCheck() and quickFcdCheck() methods return a CheckResult value to indicate whether a string is in a particular normalization form: Yes indicates that the string is in the specified form, No indicates that the string is not in the specified form, and Maybe indicates that the check was inconclusive. For example, the following code detects whether a string is in Normalization Form Composed (NFC):
 
RWUString str("This is a test.");
RWUNormalizer::CheckResult result =
RWUNormalizer::quickCheck(str, RWUNormalizer::FormNFC);
 
if (result != RWUNormalizer::Yes) {
str = RWUNormalizer::normalize(str, RWUNormalizer::FormNFC);
}
The static method quickFcdCheck() detects whether a string is in Fast C or D (FCD) form. Strictly speaking, FCD is not a normalization form, since it does not specify a unique representation for every string. Instead, it describes a string whose raw decomposition, without character reordering, results in an NFD string. Thus, all NFD, most NFC, and many unnormalized strings are already in FCD form. Such strings may be collated without further normalization. See Chapter 6 for information on collating Unicode strings using the Internationalization Module.