X hits on this document

160 views

0 shares

0 downloads

0 comments

40 / 67

16

.NET INTERNATIONALIZATION

The same difference in behavior is true for RegionInfo.DisplayName.

Custom Culture Locale IDs

Another difference between supplemental custom cultures and replacement custom cultures is their locale ID (i.e., CultureInfo.LCID). CultureAndRegionIn- foBuilder.LCID is read-only. Replacement custom cultures use the same locale ID as the cultures they replace. This is helpful because it means that there is no back door to the original culture. In the following example, both lines result in the same CultureInfo:-

CultureInfo cultureInfo1 = new CultureInfo(“en-GB”); // The LCID for en-GB is 2057 CultureInfo cultureInfo2 = new CultureInfo(2057);

In almost all cases, this behavior is desirable. It does mean, however, that it is not possible to create a CultureInfo for the original replaced culture, even if you wanted to. If this were absolutely necessary, you would have to save the replacement custom culture to an LDML file, unregister it, create an original CultureInfo object, extract the information you need, and then load the LDML file and register the replacement custom culture again.

Supplemental custom cultures all have the same locale ID: 0x1000 (4096). So the bn-BD(Bengali (Bangladesh) locale ID is 4096, and the en-GB-Acme locale ID is also 4096. Consider the following test for equality for these two cultures:

CultureInfo cultureInfo1 = new CultureInfo(“bn-BD”); CultureInfo cultureInfo2 = new CultureInfo(“en-GB-Acme”); if (! cultureInfo1.Equals(cultureInfo2))

MessageBox.Show(“CultureInfo objects are not the same”);

The CultureInfo.Equals method reports that these cultures are not equal, even though their LCIDs are the same. Two CultureInfo objects are considered equal in the .NET Framework 2.0 if they are the same object or their Names and CompareInfo objects are the same. This contrasts to the .NET Framework 1.1 implementation, which is simply based upon a comparison of LCIDs, not object references or Names.

Also note that because all supplemental custom cultures share the same LCID, it is not possible to create a supplemental custom culture using its LCID. The

Document info
Document views160
Page views160
Page last viewedTue Dec 06 12:23:45 UTC 2016
Pages67
Paragraphs859
Words13458

Comments