Click here to Skip to main content
16,011,578 members
Articles / All Topics

Shift in .NET handling of culture data

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
14 Sep 2011CPOL1 min read 10K   1  
Shift in .NET handling of culture data

There’s been a shift of handling culture data in .NET 4. This may have influences of attempts in fixing Persian culture.

The shift is simple, while prior to version 4, CLR insisted on using privately stored culture data in a “culture.nlp” binary resource, version 4 gave up and uses windows API to get data from operating system. This is why some complained about missing CultureTableRecord while using PersianCalendar.

Culture Data Prior to .NET 4

The following sequence shows how culture data are handled in prior to version 4:

  1. CultureInfo constructor calls CultureTableRecord.GetCultureTableRecord:

    image

  2. CultureTableRecord constructor uses CultureTable.Default.GetDataItemFromCultureName:image
  3. The Default property returns m_defaultInstance field which is initialized in class initializer:image
  4. Finally InitializeBaseInfoTablePointers loads “culture.nlp” from assembly resources:image
  5. where “culture.nlp” can be found in mscorlib resources:

image

There’s also a CalendarTable class with virtually the same approach:

image

CultureData in .NET 4

The above approach has been totally deprecated in .NET 4. Now CLR prefers to use Windows API to retrieve culture data. For instance, the following excerpt is from disassembly of CalandarData code where CLR attempts to enumerate optional calendars by calling EnumCalendarInfoExEx:

image

Conclusion

There’s been a shift in handling culture data in .NET 4: Now CLR prefers to use Windows API to get culture data This will have influences in fixing Persian culture as I will describe in later posts.


License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Gostareh Negar
Iran (Islamic Republic of) Iran (Islamic Republic of)
I've been programming since 1990, C, Basic, Pascal, Assembly, C++ and...
Since I restablished Gostareh Negar in 1999, I've been quite busy localizing internationally accepted software for Persian natives. So I feel quite aware of various aspects of localization, specially when Persian language is the case.

Comments and Discussions

 
-- There are no messages in this forum --