diff options
author | Tarek Mahmoud Sayed <tarekms@microsoft.com> | 2016-10-14 11:26:52 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-14 11:26:52 -0700 |
commit | c449879e7a1ec2556bcb157e86e25a8517e9bacb (patch) | |
tree | cb399e3240d70bfb3ff62e44e10ecc8eb734bbea /src/corefx | |
parent | ff3ab00d20dcf514e33c547c2c7142a626917833 (diff) | |
download | coreclr-c449879e7a1ec2556bcb157e86e25a8517e9bacb.tar.gz coreclr-c449879e7a1ec2556bcb157e86e25a8517e9bacb.tar.bz2 coreclr-c449879e7a1ec2556bcb157e86e25a8517e9bacb.zip |
Enable RegionInfo netstandard 1.7 APIs (#7604)
* Enable RegionInfo netstandard 1.7 APIs
* Fix the typo
* lowercase TRUE and FALSE
Diffstat (limited to 'src/corefx')
-rw-r--r-- | src/corefx/System.Globalization.Native/collation.cpp | 8 | ||||
-rw-r--r-- | src/corefx/System.Globalization.Native/locale.hpp | 1 | ||||
-rw-r--r-- | src/corefx/System.Globalization.Native/localeStringData.cpp | 72 |
3 files changed, 77 insertions, 4 deletions
diff --git a/src/corefx/System.Globalization.Native/collation.cpp b/src/corefx/System.Globalization.Native/collation.cpp index 6039a9ef39..42a9674632 100644 --- a/src/corefx/System.Globalization.Native/collation.cpp +++ b/src/corefx/System.Globalization.Native/collation.cpp @@ -298,7 +298,7 @@ UCollator* CloneCollatorWithOptions(const UCollator* pCollator, int32_t options, // Returns TRUE if all the collation elements in str are completely ignorable bool CanIgnoreAllCollationElements(const UCollator* pColl, const UChar* lpStr, int32_t length) { - bool result = FALSE; + bool result = false; UErrorCode err = U_ZERO_ERROR; UCollationElements* pCollElem = ucol_openElements(pColl, lpStr, length, &err); @@ -306,20 +306,20 @@ bool CanIgnoreAllCollationElements(const UCollator* pColl, const UChar* lpStr, i { int32_t curCollElem = UCOL_NULLORDER; - result = TRUE; + result = true; while ((curCollElem = ucol_next(pCollElem, &err)) != UCOL_NULLORDER) { if (curCollElem != 0) { - result = FALSE; + result = false; break; } } if (U_FAILURE(err)) { - result = FALSE; + result = false; } ucol_closeElements(pCollElem); diff --git a/src/corefx/System.Globalization.Native/locale.hpp b/src/corefx/System.Globalization.Native/locale.hpp index 4845859960..ac28fb1e02 100644 --- a/src/corefx/System.Globalization.Native/locale.hpp +++ b/src/corefx/System.Globalization.Native/locale.hpp @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. #include "unicode/locid.h" +#include "unicode/ucurr.h" /* Function: diff --git a/src/corefx/System.Globalization.Native/localeStringData.cpp b/src/corefx/System.Globalization.Native/localeStringData.cpp index 927da67095..a8dcc519ad 100644 --- a/src/corefx/System.Globalization.Native/localeStringData.cpp +++ b/src/corefx/System.Globalization.Native/localeStringData.cpp @@ -27,6 +27,8 @@ enum LocaleStringData : int32_t ThousandSeparator = 0x0000000F, Digits = 0x00000013, MonetarySymbol = 0x00000014, + CurrencyEnglishName = 0x00001007, + CurrencyNativeName = 0x00001008, Iso4217MonetarySymbol = 0x00000015, MonetaryDecimalSeparator = 0x00000016, MonetaryThousandSeparator = 0x00000017, @@ -36,6 +38,7 @@ enum LocaleStringData : int32_t NegativeSign = 0x00000051, Iso639LanguageName = 0x00000059, Iso3166CountryName = 0x0000005A, + Iso3166CountryName2= 0x00000068, NaNSymbol = 0x00000069, PositiveInfinitySymbol = 0x0000006a, ParentName = 0x0000006d, @@ -158,6 +161,66 @@ UErrorCode GetLocaleIso3166CountryName(const char* locale, UChar* value, int32_t } /* +Function: +GetLocaleIso3166CountryCode + +Gets the 3 letter country code for a locale (via uloc_getISO3Country) and converts the result to UChars +*/ +UErrorCode GetLocaleIso3166CountryCode(const char* locale, UChar* value, int32_t valueLength) +{ + const char *pIsoCountryName = uloc_getISO3Country(locale); + int len = strlen(pIsoCountryName); + + if (len == 0) + { + return U_ILLEGAL_ARGUMENT_ERROR; + } + + return u_charsToUChars_safe(pIsoCountryName, value, valueLength); +} + +/* +Function: +GetLocaleCurrencyName + +Gets the locale currency English or native name and convert the result to UChars +*/ +UErrorCode GetLocaleCurrencyName(const char* locale, bool nativeName, UChar* value, int32_t valueLength) +{ + UErrorCode status = U_ZERO_ERROR; + + UChar currencyThreeLettersName[4]; // 3 letters currency iso name + NULL + ucurr_forLocale(locale, currencyThreeLettersName, 4, &status); + if (!U_SUCCESS(status)) + { + return status; + } + + int32_t len; + UBool formatChoice; + const UChar *pCurrencyLongName = ucurr_getName( + currencyThreeLettersName, + nativeName ? locale : ULOC_US, + UCURR_LONG_NAME, + &formatChoice, + &len, + &status); + if (!U_SUCCESS(status)) + { + return status; + } + + if (len >= valueLength) // we need to have room for NULL too + { + return U_BUFFER_OVERFLOW_ERROR; + } + u_strncpy(value, pCurrencyLongName, len); + value[len] = 0; + + return status; +} + +/* PAL Function: GetLocaleInfoString @@ -226,6 +289,12 @@ extern "C" int32_t GlobalizationNative_GetLocaleInfoString( case Iso4217MonetarySymbol: status = GetLocaleInfoDecimalFormatSymbol(locale, UNUM_INTL_CURRENCY_SYMBOL, value, valueLength); break; + case CurrencyEnglishName: + status = GetLocaleCurrencyName(locale, false, value, valueLength); + break; + case CurrencyNativeName: + status = GetLocaleCurrencyName(locale, true, value, valueLength); + break; case MonetaryDecimalSeparator: status = GetLocaleInfoDecimalFormatSymbol(locale, UNUM_MONETARY_SEPARATOR_SYMBOL, value, valueLength); break; @@ -251,6 +320,9 @@ extern "C" int32_t GlobalizationNative_GetLocaleInfoString( case Iso3166CountryName: status = GetLocaleIso3166CountryName(locale, value, valueLength); break; + case Iso3166CountryName2: + status = GetLocaleIso3166CountryCode(locale, value, valueLength); + break; case NaNSymbol: status = GetLocaleInfoDecimalFormatSymbol(locale, UNUM_NAN_SYMBOL, value, valueLength); break; |