private static int GetWsFromString(ITsString tss, int ichMin, int ichLim)
{
if (tss == null || tss.Length == 0 || ichMin >= ichLim)
return 0;
int runMin = tss.get_RunAt(ichMin);
int runMax = tss.get_RunAt(ichLim - 1);
int ws = tss.get_WritingSystem(runMin);
if (runMin == runMax)
return ws;
for (int i = runMin + 1; i <= runMax; ++i)
{
int wsT = tss.get_WritingSystem(i);
if (wsT != ws)
return 0;
}
return ws;
}