// 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);
{
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);
// See the LICENSE file in the project root for more information.
#include "unicode/locid.h"
+#include "unicode/ucurr.h"
/*
Function:
ThousandSeparator = 0x0000000F,
Digits = 0x00000013,
MonetarySymbol = 0x00000014,
+ CurrencyEnglishName = 0x00001007,
+ CurrencyNativeName = 0x00001008,
Iso4217MonetarySymbol = 0x00000015,
MonetaryDecimalSeparator = 0x00000016,
MonetaryThousandSeparator = 0x00000017,
NegativeSign = 0x00000051,
Iso639LanguageName = 0x00000059,
Iso3166CountryName = 0x0000005A,
+ Iso3166CountryName2= 0x00000068,
NaNSymbol = 0x00000069,
PositiveInfinitySymbol = 0x0000006a,
ParentName = 0x0000006d,
}
/*
+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
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;
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;
get { return Environment.GetResourceString("Argument_CultureNotSupported"); }
}
+ public static string Argument_CultureIsNeutral
+ {
+ get { return Environment.GetResourceString("Argument_CultureIsNeutral"); }
+ }
+
public static string Argument_CustomCultureCannotBePassedByNumber
{
get { return Environment.GetResourceString("Argument_CustomCultureCannotBePassedByNumber"); }
int ebcdicCodePage = LocaleData.GetLocaleDataNumericPart(cultureName, LocaleDataParts.EbcdicCodePage);
return ebcdicCodePage == -1 ? CultureData.Invariant.IDEFAULTEBCDICCODEPAGE : ebcdicCodePage;
}
+
+ private static int GetGeoId(string cultureName)
+ {
+ int geoId = LocaleData.GetLocaleDataNumericPart(cultureName, LocaleDataParts.GeoId);
+ return geoId == -1 ? CultureData.Invariant.IGEOID : geoId;
+ }
}
}
{
throw new NotImplementedException();
}
+
+ private static int GetGeoId(string cultureName)
+ {
+ throw new NotImplementedException();
+ }
}
}
private String _sEnglishCountry; // english country name (RegionInfo)
private String _sNativeCountry; // native country name
private String _sISO3166CountryName; // ISO 3166 (RegionInfo), ie: US
+ private String _sISO3166CountryName2; // 3 char ISO 3166 country name 2 2(RegionInfo) ex: USA (ISO)
+ private int _iGeoId = undef; // GeoId
// Numbers
private String _sPositiveSign; // (user can override) positive sign
// Currency
private String _sCurrency; // (user can override) local monetary symbol
private String _sIntlMonetarySymbol; // international monetary symbol (RegionInfo)
+ private String _sEnglishCurrency; // English name for this currency
+ private String _sNativeCurrency; // Native name for this currency
// (nfi populates these 4, don't have to be = undef)
private int _iCurrencyDigits; // (user can override) # local monetary fractional digits
private int _iCurrency; // (user can override) positive currency format
invariant._sNativeLanguage = "Invariant Language"; // Native name of this language
// Region
- invariant._sRegionName = "IV"; // (RegionInfo)
- invariant._sEnglishCountry = "Invariant Country"; // english country name (RegionInfo)
- invariant._sNativeCountry = "Invariant Country"; // native country name (Windows Only)
- invariant._sISO3166CountryName = "IV"; // (RegionInfo), ie: US
+ invariant._sRegionName = "IV"; // (RegionInfo)
+ invariant._sEnglishCountry = "Invariant Country"; // english country name (RegionInfo)
+ invariant._sNativeCountry = "Invariant Country"; // native country name (Windows Only)
+ invariant._sISO3166CountryName = "IV"; // (RegionInfo), ie: US
+ invariant._sISO3166CountryName2 = "ivc"; // 3 char ISO 3166 country name 2 2(RegionInfo)
+ invariant._iGeoId = 244; // GeoId (Windows Only)
// Numbers
invariant._sPositiveSign = "+"; // positive sign
// Currency
invariant._sCurrency = "\x00a4"; // local monetary symbol: for international monetary symbol
invariant._sIntlMonetarySymbol = "XDR"; // international monetary symbol (RegionInfo)
+ invariant._sEnglishCurrency = "International Monetary Fund"; // English name for this currency (Windows Only)
+ invariant._sNativeCurrency = "International Monetary Fund"; // Native name for this currency (Windows Only)
invariant._iCurrencyDigits = 2; // # local monetary fractional digits
invariant._iCurrency = 0; // positive currency format
invariant._iNegativeCurrency = 0; // negative currency format
// These are desktop only, not coreclr
- invariant._iLanguage = 0x007f; // locale ID (0409) - NO sort information
+ invariant._iLanguage = CultureInfo.LOCALE_INVARIANT; // locale ID (0409) - NO sort information
invariant._iDefaultAnsiCodePage = 1252; // default ansi code page ID (ACP)
invariant._iDefaultOemCodePage = 437; // default oem code page ID (OCP or OEM)
invariant._iDefaultMacCodePage = 10000; // default macintosh code page
string localeName = null;
CultureData retVal = null;
- if (culture == 0x007f)
+ if (culture == CultureInfo.LOCALE_INVARIANT)
return Invariant;
// Convert the lcid to a name, then use that
}
}
+ internal int IGEOID
+ {
+ get
+ {
+ if (_iGeoId == undef)
+ {
+ _iGeoId = GetGeoId(_sRealName);
+ }
+ return _iGeoId;
+ }
+ }
// localized name for the country
internal string SLOCALIZEDCOUNTRY
}
}
+ // 3 letter ISO 3166 country code
+ internal String SISO3166CTRYNAME2
+ {
+ get
+ {
+ if (_sISO3166CountryName2 == null)
+ {
+ _sISO3166CountryName2 = GetLocaleInfo(LocaleStringData.Iso3166CountryName2);
+ }
+ return _sISO3166CountryName2;
+ }
+ }
+
/////////////
// Numbers //
////////////
}
}
+ // English name for this currency (RegionInfo), eg: US Dollar
+ internal String SENGLISHCURRENCY
+ {
+ get
+ {
+ if (_sEnglishCurrency == null)
+ {
+ _sEnglishCurrency = GetLocaleInfo(LocaleStringData.CurrencyEnglishName);
+ }
+ return _sEnglishCurrency;
+ }
+ }
+
+ // Native name for this currency (RegionInfo), eg: Schweiz Frank
+ internal String SNATIVECURRENCY
+ {
+ get
+ {
+ if (_sNativeCurrency == null)
+ {
+ _sNativeCurrency = GetLocaleInfo(LocaleStringData.CurrencyNativeName);
+ }
+ return _sNativeCurrency;
+ }
+ }
+
// internal int iCurrencyDigits ; // (user can override) # local monetary fractional digits
// internal int iCurrency ; // (user can override) positive currency format
// internal int iNegativeCurrency ; // (user can override) negative currency format
Digits = 0x00000013,
/// <summary>local monetary symbol (coresponds to LOCALE_SCURRENCY)</summary>
MonetarySymbol = 0x00000014,
+ /// <summary>English currency name (coresponds to LOCALE_SENGCURRNAME)</summary>
+ CurrencyEnglishName = 0x00001007,
+ /// <summary>Native currency name (coresponds to LOCALE_SNATIVECURRNAME)</summary>
+ CurrencyNativeName = 0x00001008,
/// <summary>uintl monetary symbol (coresponds to LOCALE_SINTLSYMBOL)</summary>
Iso4217MonetarySymbol = 0x00000015,
/// <summary>monetary decimal separator (coresponds to LOCALE_SMONDECIMALSEP)</summary>
Iso639LanguageName = 0x00000059,
/// <summary>ISO abbreviated country name (coresponds to LOCALE_SISO3166CTRYNAME)</summary>
Iso3166CountryName = 0x0000005A,
+ /// <summary>3 letter ISO country code (coresponds to LOCALE_SISO3166CTRYNAME2)</summary>
+ Iso3166CountryName2 = 0x00000068, // 3 character ISO country name
/// <summary>Not a Number (coresponds to LOCALE_SNAN)</summary>
NaNSymbol = 0x00000069,
/// <summary>+ Infinity (coresponds to LOCALE_SPOSINFINITY)</summary>
// LOCALE constants of interest to us internally and privately for LCID functions
// (ie: avoid using these and use names if possible)
- private const int LOCALE_NEUTRAL = 0x0000;
+ internal const int LOCALE_NEUTRAL = 0x0000;
private const int LOCALE_USER_DEFAULT = 0x0400;
private const int LOCALE_SYSTEM_DEFAULT = 0x0800;
internal const int LOCALE_CUSTOM_UNSPECIFIED = 0x1000;
- internal const int LOCALE_CUSTOM_DEFAULT = 0x0c00;
+ internal const int LOCALE_CUSTOM_DEFAULT = 0x0c00;
+ internal const int LOCALE_INVARIANT = 0x007F;
static AsyncLocal<CultureInfo> s_asyncLocalCurrentCulture;
static AsyncLocal<CultureInfo> s_asyncLocalCurrentUICulture;
{
internal enum LocaleDataParts
{
- Lcid = 0,
- AnsiCodePage = 1,
- OemCodePage = 2,
- MacCodePage = 3,
+ Lcid = 0,
+ AnsiCodePage = 1,
+ OemCodePage = 2,
+ MacCodePage = 3,
EbcdicCodePage = 4,
- GeoId = 5
+ GeoId = 5
}
internal partial class LocaleData
SetName(name);
}
+ [System.Security.SecuritySafeCritical] // auto-generated
+ public RegionInfo(int culture)
+ {
+ if (culture == CultureInfo.LOCALE_INVARIANT) //The InvariantCulture has no matching region
+ {
+ throw new ArgumentException(SR.Argument_NoRegionInvariantCulture);
+ }
+
+ if (culture == CultureInfo.LOCALE_NEUTRAL)
+ {
+ // Not supposed to be neutral
+ throw new ArgumentException(SR.Format(SR.Argument_CultureIsNeutral, culture), "culture");
+ }
+
+ if (culture == CultureInfo.LOCALE_CUSTOM_DEFAULT)
+ {
+ // Not supposed to be neutral
+ throw new ArgumentException(SR.Format(SR.Argument_CustomCultureCannotBePassedByNumber, culture), "culture");
+ }
+
+ _cultureData = CultureData.GetCultureData(culture, true);
+ _name = _cultureData.SREGIONNAME;
+
+ if (_cultureData.IsNeutralCulture)
+ {
+ // Not supposed to be neutral
+ throw new ArgumentException(SR.Format(SR.Argument_CultureIsNeutral, culture), "culture");
+ }
+ }
+
internal RegionInfo(CultureData cultureData)
{
_cultureData = cultureData;
////////////////////////////////////////////////////////////////////////
//
+ // ThreeLetterISORegionName
+ //
+ // Returns the three letter ISO region name (ie: USA)
+ //
+ ////////////////////////////////////////////////////////////////////////
+ public virtual String ThreeLetterISORegionName
+ {
+ get
+ {
+ return (_cultureData.SISO3166CTRYNAME2);
+ }
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ //
+ // ThreeLetterWindowsRegionName
+ //
+ // Returns the three letter windows region name (ie: USA)
+ //
+ ////////////////////////////////////////////////////////////////////////
+ public virtual String ThreeLetterWindowsRegionName
+ {
+ get
+ {
+ // ThreeLetterWindowsRegionName is really same as ThreeLetterISORegionName
+ return ThreeLetterISORegionName;
+ }
+ }
+
+
+ ////////////////////////////////////////////////////////////////////////
+ //
// IsMetric
//
// Returns true if this region uses the metric measurement system
}
}
+ [System.Runtime.InteropServices.ComVisible(false)]
+ public virtual int GeoId
+ {
+ get
+ {
+ return (_cultureData.IGEOID);
+ }
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ //
+ // CurrencyEnglishName
+ //
+ // English name for this region's currency, ie: Swiss Franc
+ //
+ ////////////////////////////////////////////////////////////////////////
+ [System.Runtime.InteropServices.ComVisible(false)]
+ public virtual string CurrencyEnglishName
+ {
+ get
+ {
+ return (_cultureData.SENGLISHCURRENCY);
+ }
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ //
+ // CurrencyNativeName
+ //
+ // Native name for this region's currency, ie: Schweizer Franken
+ // WARNING: You need a full locale name for this to make sense.
+ //
+ ////////////////////////////////////////////////////////////////////////
+ [System.Runtime.InteropServices.ComVisible(false)]
+ public virtual string CurrencyNativeName
+ {
+ get
+ {
+ return (_cultureData.SNATIVECURRENCY);
+ }
+ }
+
////////////////////////////////////////////////////////////////////////
//
// CurrencySymbol
[System.Runtime.InteropServices.ComVisibleAttribute(false)]
public string[] NativeDigits { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } }
}
-
- public partial class RegionInfo
- {
- public RegionInfo(int culture) { throw new NotImplementedException(); }
- [System.Runtime.InteropServices.ComVisibleAttribute(false)]
- public virtual string CurrencyEnglishName { get { throw new NotImplementedException(); } }
- [System.Runtime.InteropServices.ComVisibleAttribute(false)]
- public virtual string CurrencyNativeName { get { throw new NotImplementedException(); } }
- [System.Runtime.InteropServices.ComVisibleAttribute(false)]
- public virtual int GeoId { get { throw new NotImplementedException(); } }
- public virtual string ThreeLetterISORegionName { get { throw new NotImplementedException(); } }
- public virtual string ThreeLetterWindowsRegionName { get { throw new NotImplementedException(); } }
- }
}
\ No newline at end of file