public static bool GreekToInteger(string greekLetterName, out int index, out string baseName )
{
// greekMap is static, and we only need to populate it once in
// the lifetime of the KSP process. We'll do so the first time
// this method (the only one that uses it) gets called:
if (greekMap == null)
InitializeGreekMap();
// Get lastmost word (or whole string if there's no spaces):
int lastSpace = greekLetterName.LastIndexOf(' ');
string lastTerm;
if (lastSpace >= 0 && lastSpace < greekLetterName.Length - 1)
{
// last space is real, and isn't the lastmost char but actually has
// nonspaces that follow it:
lastTerm = greekLetterName.Substring(lastSpace+1).ToLower(); // ToLower for the dictionary hashmap lookup
baseName = greekLetterName.Substring(0,lastSpace);
}
else
{
lastTerm = greekLetterName.ToLower(); // ToLower for the dictionary hashmap lookup
baseName = greekLetterName;
}
bool worked = greekMap.TryGetValue(lastTerm, out index);
if (!worked)
index = -1;
return worked;
}