byte[] FixupString(string s) { byte[] fix; if (_stringFixups.TryGetValue(s, out fix)) { return(fix); } else { fix = MacRomanEncoding.GetBytes(s.Replace("\u03A9", "Ohm")); _stringFixups[s] = fix; return(fix); //var n = s.Length; //var bad = false; //for (var i = 0; i < n && !bad; i++) //{ // bad = ((int)s[i] > 127); //} //if (bad) //{ // fix = MacRomanEncoding.GetBytes(s.Replace("\u03A9", "Ohm")); // _stringFixups[s] = fix; // return fix; //} //else //{ // return null; //} } }
byte[] FixupString(string s) { byte[] fix; if (_stringFixups.TryGetValue(s, out fix)) { return(fix); } else { var n = s.Length; var bad = false; for (var i = 0; i < n && !bad; i++) { bad = ((int)s[i] > 127); } if (bad) { fix = MacRomanEncoding.GetBytes(s.Replace("\u03A9", "Ohm")); _stringFixups [s] = fix; return(fix); } else { return(null); } } }