gecko-dev/intl/icu-patches/bug-1422415-numberformat-sp...

31 строка
1.2 KiB
Diff

Bug 1422415 - NumberFormat returns NaN if RegionalPrefsLocales is fa-IR and value has decimals
https://ssl.icu-project.org/trac/ticket/13497
diff --git a/intl/icu/source/i18n/digitlst.cpp b/intl/icu/source/i18n/digitlst.cpp
--- a/intl/icu/source/i18n/digitlst.cpp
+++ b/intl/icu/source/i18n/digitlst.cpp
@@ -846,17 +846,22 @@ DigitList::set(double source)
// That is why infinity is special cased here.
if (uprv_isInfinite(source)) {
if (uprv_isNegativeInfinity(source)) {
uprv_strcpy(rep,"-inf"); // Handle negative infinity
} else {
uprv_strcpy(rep,"inf");
}
} else {
+#if U_USE_STRTOD_L && U_PLATFORM_USES_ONLY_WIN32_API
+ umtx_initOnce(gCLocaleInitOnce, &initCLocale);
+ _sprintf_l(rep, "%+1.*e", gCLocale, MAX_DBL_DIGITS - 1, source);
+#else
sprintf(rep, "%+1.*e", MAX_DBL_DIGITS - 1, source);
+#endif
}
U_ASSERT(uprv_strlen(rep) < sizeof(rep));
// uprv_decNumberFromString() will parse the string expecting '.' as a
// decimal separator, however sprintf() can use ',' in certain locales.
// Overwrite a ',' with '.' here before proceeding.
char *decimalSeparator = strchr(rep, ',');
if (decimalSeparator != NULL) {