public UnicodeNormalizerConformanceTest() { // Doesn't matter what the string and mode are; we'll change // them later as needed. normalizer_C = new UnicodeNormalizer(UnicodeNormalizer.C, true); normalizer_D = new UnicodeNormalizer(UnicodeNormalizer.D, false); normalizer_KC = new UnicodeNormalizer(UnicodeNormalizer.KC, false); normalizer_KD = new UnicodeNormalizer(UnicodeNormalizer.KD, false); }
public void TestNormalize() { if (unicode_NFD == null) { try { unicode_NFD = new UnicodeNormalizer(UnicodeNormalizer.D, true); unicode_NFC = new UnicodeNormalizer(UnicodeNormalizer.C, true); unicode_NFKD = new UnicodeNormalizer(UnicodeNormalizer.KD, true); unicode_NFKC = new UnicodeNormalizer(UnicodeNormalizer.KC, true); } catch (Exception e) { Errln("Normalization tests could not be run: " + e.ToString()); } } int i = 0; while (i < loopCount) { String source = GetTestSource(); Logln("Test source:" + source); //NFD String uncodeNorm = unicode_NFD.normalize(source); String icuNorm = Normalizer.Normalize(source, Normalizer.NFD); Logln("\tNFD(Unicode): " + uncodeNorm); Logln("\tNFD(icu4j) : " + icuNorm); if (!uncodeNorm.Equals(icuNorm)) { Errln("NFD: Unicode sample output => " + uncodeNorm + "; icu4j output=> " + icuNorm); } //NFC uncodeNorm = unicode_NFC.normalize(source); icuNorm = Normalizer.Normalize(source, Normalizer.NFC); Logln("\tNFC(Unicode): " + uncodeNorm); Logln("\tNFC(icu4j) : " + icuNorm); if (!uncodeNorm.Equals(icuNorm)) { Errln("NFC: Unicode sample output => " + uncodeNorm + "; icu4j output=> " + icuNorm); } //NFKD uncodeNorm = unicode_NFKD.normalize(source); icuNorm = Normalizer.Normalize(source, Normalizer.NFKD); Logln("\tNFKD(Unicode): " + uncodeNorm); Logln("\tNFKD(icu4j) : " + icuNorm); if (!uncodeNorm.Equals(icuNorm)) { Errln("NFKD: Unicode sample output => " + uncodeNorm + "; icu4j output=> " + icuNorm); } //NFKC uncodeNorm = unicode_NFKC.normalize(source); icuNorm = Normalizer.Normalize(source, Normalizer.NFKC); Logln("\tNFKC(Unicode): " + uncodeNorm); Logln("\tNFKC(icu4j) : " + icuNorm); if (!uncodeNorm.Equals(icuNorm)) { Errln("NFKC: Unicode sample output => " + uncodeNorm + "; icu4j output=> " + icuNorm); } i++; } }