8 namespace Mono.Tools.LocaleBuilder {
12 protected static String EncodeString (string str)
17 StringBuilder ret = new StringBuilder ();
18 byte [] ba = new UTF8Encoding ().GetBytes (str);
20 foreach (byte b in ba) {
21 if (b > 127 || (in_hex && is_hex (b))) {
22 ret.AppendFormat ("\\x{0:x}", b);
27 ret.Append ((char) b);
31 return ret.ToString ();
34 private static bool is_hex (int e)
36 return (e >= '0' && e <= '9') || (e >= 'A' && e <= 'F') || (e >= 'a' && e <= 'f');