summaryrefslogtreecommitdiffstats
path: root/thirdparty/icu4c/common/loadednormalizer2impl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/icu4c/common/loadednormalizer2impl.cpp')
-rw-r--r--thirdparty/icu4c/common/loadednormalizer2impl.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/thirdparty/icu4c/common/loadednormalizer2impl.cpp b/thirdparty/icu4c/common/loadednormalizer2impl.cpp
index 768564edc8..99b8f3e86c 100644
--- a/thirdparty/icu4c/common/loadednormalizer2impl.cpp
+++ b/thirdparty/icu4c/common/loadednormalizer2impl.cpp
@@ -143,6 +143,9 @@ static icu::UInitOnce nfkcInitOnce {};
static Norm2AllModes *nfkc_cfSingleton;
static icu::UInitOnce nfkc_cfInitOnce {};
+static Norm2AllModes *nfkc_scfSingleton;
+static icu::UInitOnce nfkc_scfInitOnce {};
+
static UHashtable *cache=nullptr;
// UInitOnce singleton initialization function
@@ -156,6 +159,8 @@ static void U_CALLCONV initSingletons(const char *what, UErrorCode &errorCode) {
nfkcSingleton = Norm2AllModes::createInstance(nullptr, "nfkc", errorCode);
} else if (uprv_strcmp(what, "nfkc_cf") == 0) {
nfkc_cfSingleton = Norm2AllModes::createInstance(nullptr, "nfkc_cf", errorCode);
+ } else if (uprv_strcmp(what, "nfkc_scf") == 0) {
+ nfkc_scfSingleton = Norm2AllModes::createInstance(nullptr, "nfkc_scf", errorCode);
} else {
UPRV_UNREACHABLE_EXIT; // Unknown singleton
}
@@ -183,6 +188,10 @@ static UBool U_CALLCONV uprv_loaded_normalizer2_cleanup() {
nfkc_cfSingleton = nullptr;
nfkc_cfInitOnce.reset();
+ delete nfkc_scfSingleton;
+ nfkc_scfSingleton = nullptr;
+ nfkc_scfInitOnce.reset();
+
uhash_close(cache);
cache=nullptr;
return true;
@@ -213,6 +222,13 @@ Norm2AllModes::getNFKC_CFInstance(UErrorCode &errorCode) {
return nfkc_cfSingleton;
}
+const Norm2AllModes *
+Norm2AllModes::getNFKC_SCFInstance(UErrorCode &errorCode) {
+ if(U_FAILURE(errorCode)) { return nullptr; }
+ umtx_initOnce(nfkc_scfInitOnce, &initSingletons, "nfkc_scf", errorCode);
+ return nfkc_scfSingleton;
+}
+
#if !NORM2_HARDCODE_NFC_DATA
const Normalizer2 *
Normalizer2::getNFCInstance(UErrorCode &errorCode) {
@@ -262,6 +278,12 @@ Normalizer2::getNFKCCasefoldInstance(UErrorCode &errorCode) {
}
const Normalizer2 *
+Normalizer2::getNFKCSimpleCasefoldInstance(UErrorCode &errorCode) {
+ const Norm2AllModes *allModes=Norm2AllModes::getNFKC_SCFInstance(errorCode);
+ return allModes!=nullptr ? &allModes->comp : nullptr;
+}
+
+const Normalizer2 *
Normalizer2::getInstance(const char *packageName,
const char *name,
UNormalization2Mode mode,
@@ -281,6 +303,8 @@ Normalizer2::getInstance(const char *packageName,
allModes=Norm2AllModes::getNFKCInstance(errorCode);
} else if(0==uprv_strcmp(name, "nfkc_cf")) {
allModes=Norm2AllModes::getNFKC_CFInstance(errorCode);
+ } else if(0==uprv_strcmp(name, "nfkc_scf")) {
+ allModes=Norm2AllModes::getNFKC_SCFInstance(errorCode);
}
}
if(allModes==nullptr && U_SUCCESS(errorCode)) {
@@ -394,6 +418,11 @@ unorm2_getNFKCCasefoldInstance(UErrorCode *pErrorCode) {
}
U_CAPI const UNormalizer2 * U_EXPORT2
+unorm2_getNFKCSimpleCasefoldInstance(UErrorCode *pErrorCode) {
+ return (const UNormalizer2 *)Normalizer2::getNFKCSimpleCasefoldInstance(*pErrorCode);
+}
+
+U_CAPI const UNormalizer2 * U_EXPORT2
unorm2_getInstance(const char *packageName,
const char *name,
UNormalization2Mode mode,