Skip to content

Instantly share code, notes, and snippets.

@leppie
Created September 16, 2013 19:05
Show Gist options
  • Save leppie/6585049 to your computer and use it in GitHub Desktop.
Save leppie/6585049 to your computer and use it in GitHub Desktop.
static unsafe CharUnicodeInfo()
{
m_pDataTable = GlobalizationAssembly.GetGlobalizationResourceBytePtr(typeof(CharUnicodeInfo).Assembly, "charinfo.nlp");
UnicodeDataHeader* pDataTable = (UnicodeDataHeader*) m_pDataTable;
m_pCategoryLevel1Index = (ushort*) (m_pDataTable + pDataTable->OffsetToCategoriesIndex);
m_pCategoriesValue = m_pDataTable + ((byte*) pDataTable->OffsetToCategoriesValue);
m_pNumericLevel1Index = (ushort*) (m_pDataTable + pDataTable->OffsetToNumbericIndex);
m_pNumericValues = m_pDataTable + ((byte*) pDataTable->OffsetToNumbericValue);
m_pDigitValues = (DigitValues*) (m_pDataTable + pDataTable->OffsetToDigitValue);
nativeInitTable(m_pDataTable);
}
internal static unsafe byte InternalGetCategoryValue(int ch, int offset)
{
ushort num = m_pCategoryLevel1Index[ch >> 8];
num = m_pCategoryLevel1Index[num + ((ch >> 4) & 15)];
byte* numPtr = (byte*) (m_pCategoryLevel1Index + num);
byte num2 = numPtr[ch & 15];
return m_pCategoriesValue[(num2 * 2) + offset];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment