unsafe internal int GetDataItemFromCultureName(String name, out int culture, out String actualName) {
BCLDebug.Assert(name!=null,"CultureTable.GetDataItemFromCultureName(): name!=null");
culture = -1;
actualName = "";
CultureTableItem cti = (CultureTableItem)hashByName[name];
if(null != cti &&
0 != cti.culture) {
culture = cti.culture;
actualName = cti.name;
return (cti.dataItem);
}
int left = 0;
int right = m_pCultureHeader->numCultureNames - 1;
while (left <= right) {
int mid = (left+right)/2;
int result = CompareStringToStringPoolStringBinary(name, m_pCultureNameIndex[mid].strOffset);
if (result == 0) {
cti = new CultureTableItem();
int index = cti.dataItem = m_pCultureNameIndex[mid].dataItemIndex;
culture = cti.culture = m_pCultureNameIndex[mid].actualCultureID;
actualName = cti.name = GetStringPoolString(m_pCultureNameIndex[mid].strOffset);
// m_pCultureNameIndex[i].dateItemIndex is the record number for
// the information of a culture.
// The trick that we play to remove es-ES-Ts is to put a duplicate entry
// in the name offset table for es-ES, so that es-ES-Ts is not in the name offset table
// Therefore, es-ES-Ts becomes an invalid name.
// However, the data item for es-ES-Ts is still there. It is just that
// you can not find it by calling GetDataItemFromName.
hashByName[name] = cti;
return (index);
}
if (result < 0) {
right = mid - 1;
} else {
left = mid + 1;
}
}
culture = -1;
return (-1);
}