diff --git a/icu4c/source/common/sprpimpl.h b/icu4c/source/common/sprpimpl.h index ee2128ba18c..7a5e17d204a 100644 --- a/icu4c/source/common/sprpimpl.h +++ b/icu4c/source/common/sprpimpl.h @@ -39,6 +39,7 @@ enum UStringPrepType{ typedef enum UStringPrepType UStringPrepType; +#ifdef USPREP_TYPE_NAMES_ARRAY static const char* usprepTypeNames[] ={ "UNASSIGNED" , "MAP" , @@ -47,6 +48,8 @@ static const char* usprepTypeNames[] ={ "DELETE", "TYPE_LIMIT" }; +#endif + enum{ _SPREP_NORMALIZATION_ON = 0x0001, _SPREP_CHECK_BIDI_ON = 0x0002 diff --git a/icu4c/source/test/cintltst/sprpdata.c b/icu4c/source/test/cintltst/sprpdata.c index 6f0a1ba2dba..ed70efd0ef4 100644 --- a/icu4c/source/test/cintltst/sprpdata.c +++ b/icu4c/source/test/cintltst/sprpdata.c @@ -15,6 +15,8 @@ */ #if !UCONFIG_NO_IDNA +#define USPREP_TYPE_NAMES_ARRAY + #include "unicode/utypes.h" #include "unicode/ustring.h" #include "cintltst.h" diff --git a/icu4c/source/test/intltest/nptrans.cpp b/icu4c/source/test/intltest/nptrans.cpp index 76d6145161c..c84f7b23a56 100644 --- a/icu4c/source/test/intltest/nptrans.cpp +++ b/icu4c/source/test/intltest/nptrans.cpp @@ -63,8 +63,11 @@ NamePrepTransform::NamePrepTransform(UParseError& parseError, UErrorCode& status // create the mapping transliterator int32_t ruleLen = 0; const UChar* ruleUChar = ures_getStringByKey(bundle, "MapNFKC",&ruleLen, &status); - UnicodeString rule(ruleUChar, ruleLen); - + int32_t mapRuleLen = 0; + const UChar *mapRuleUChar = ures_getStringByKey(bundle, "MapNoNormalization", &mapRuleLen, &status); + UnicodeString rule(mapRuleUChar, mapRuleLen); + rule.append(ruleUChar, ruleLen); + mapping = Transliterator::createFromRules(UnicodeString("NamePrepTransform", ""), rule, UTRANS_FORWARD, parseError,status); if(U_FAILURE(status)) { diff --git a/icu4c/source/test/intltest/testidn.cpp b/icu4c/source/test/intltest/testidn.cpp index ca70091a808..f85cce37d16 100644 --- a/icu4c/source/test/intltest/testidn.cpp +++ b/icu4c/source/test/intltest/testidn.cpp @@ -25,6 +25,8 @@ #if !UCONFIG_NO_IDNA && !UCONFIG_NO_TRANSLITERATION +#define USPREP_TYPE_NAMES_ARRAY + #include "unicode/uchar.h" #include "unicode/putil.h" #include "cmemory.h" diff --git a/icu4c/source/test/intltest/testidna.cpp b/icu4c/source/test/intltest/testidna.cpp index 32e88e94319..4f8c75baf89 100644 --- a/icu4c/source/test/intltest/testidna.cpp +++ b/icu4c/source/test/intltest/testidna.cpp @@ -146,8 +146,8 @@ static UChar unicodeIn[][41] ={ 0x043e, 0x043d, 0x0438, 0x043d, 0x0435, 0x0433, 0x043e, 0x0432, 0x043e, 0x0440, 0x044f, 0x0442, 0x043f, 0x043e, 0x0440, 0x0443, 0x0441, 0x0441, 0x043a, 0x0438 - } - + }, + }; static const char *asciiIn[] = { @@ -174,7 +174,6 @@ static const char *asciiIn[] = { "xn--hxargifdar", // Greek "xn--bonusaa-5bb1da", // Maltese "xn--b1abfaaepdrnnbgefbadotcwatmq2g4l", // Russian (Cyrillic) - }; static const char *domainNames[] = { @@ -1573,6 +1572,27 @@ void TestIDNA::TestIDNAMonkeyTest(){ source.append("\\uCF18\\U00021161\\U000EEF11\\U0002BB82\\U0001D63C"); debug(source.getBuffer(),source.length(),UIDNA_ALLOW_UNASSIGNED); source.releaseBuffer(); + + { // test deletion of code points + UnicodeString source("\\u043f\\u00AD\\u034f\\u043e\\u0447\\u0435\\u043c\\u0443\\u0436\\u0435\\u043e\\u043d\\u0438\\u043d\\u0435\\u0433\\u043e\\u0432\\u043e\\u0440\\u044f\\u0442\\u043f\\u043e\\u0440\\u0443\\u0441\\u0441\\u043a\\u0438\\u0000"); + source = source.unescape(); + UnicodeString expected("\\u043f\\u043e\\u0447\\u0435\\u043c\\u0443\\u0436\\u0435\\u043e\\u043d\\u0438\\u043d\\u0435\\u0433\\u043e\\u0432\\u043e\\u0440\\u044f\\u0442\\u043f\\u043e\\u0440\\u0443\\u0441\\u0441\\u043a\\u0438\\u0000"); + expected = expected.unescape(); + UnicodeString ascii("xn--b1abfaaepdrnnbgefbadotcwatmq2g4l"); + ascii.append((UChar)0x0000); + testAPI(source.getBuffer(),ascii.getBuffer(), "uidna_toASCII", FALSE, U_ZERO_ERROR, TRUE, TRUE, uidna_toASCII); + source.releaseBuffer(); + ascii.releaseBuffer(); + + testAPI(source.getBuffer(),ascii.getBuffer(), "idnaref_toASCII", FALSE, U_ZERO_ERROR, TRUE, TRUE, idnaref_toASCII); + source.releaseBuffer(); + ascii.releaseBuffer(); + + + testCompareReferenceImpl(source.getBuffer(), source.length()-1); + source.releaseBuffer(); + + } } diff --git a/icu4c/source/tools/gensprep/gensprep.c b/icu4c/source/tools/gensprep/gensprep.c index 5763c4e6134..0233a105cb0 100644 --- a/icu4c/source/tools/gensprep/gensprep.c +++ b/icu4c/source/tools/gensprep/gensprep.c @@ -19,6 +19,8 @@ * in various StringPrep conversion processes. */ +#define USPREP_TYPE_NAMES_ARRAY 1 + #include #include