Babak Mahmoudi's Blog

Localization for Persian Language…

Shift in .Net handling of culture data

leave a comment »

There’s been a shift of handling culture data in .Net 4. This may have influences on 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

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

  1. CultureInfo constructor calls CultureTableRecord.GetCultureTableRecord


  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:


There’s also a CalendarTable class with virtually same approach



CultureData in .Net 4

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



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.


Written by Babak Mahmoudi

September 14, 2011 at 9:11 am

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: