private static int[] DiffCodes(string aText, Hashtable h, bool trimSpace, bool ignoreSpace, bool ignoreCase)
{
// get all codes of the text
string[] Lines;
int[] Codes;
int lastUsedCode = h.Count;
object aCode;
string s;
// strip off all cr, only use lf as textline separator.
aText = aText.Replace("\r", "");
Lines = aText.Split('\n');
Codes = new int[Lines.Length];
for (int i = 0; i < Lines.Length; ++i)
{
s = Lines[i];
if (trimSpace)
s = s.Trim();
if (ignoreSpace)
{
s = Regex.Replace(s, "\\s+", " "); // TODO: optimization: faster blank removal.
}
if (ignoreCase)
s = s.ToLower();
aCode = h[s];
if (aCode == null)
{
lastUsedCode++;
h[s] = lastUsedCode;
Codes[i] = lastUsedCode;
}
else {
Codes[i] = (int)aCode;
} // if
} // for
return (Codes);
} // DiffCodes