public static String toHexString(String s) {StringBuilder sb = new StringBuilder();for(int i=0;i<s.length();i++) {char ch = s.charAt(i);if (i > 0) {sb.append(' ');}if (ch < 128) {sb.append(ch);} else {if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) {sb.append("H:");} else if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) {sb.append("L:");} else if (ch > UNI_SUR_LOW_END) {if (ch == 0xffff) {sb.append("F:");} else {sb.append("E:");}}sb.append("0x").append(Integer.toHexString(ch));}}return sb.toString();}

public static string ToHexString(string s){var sb = new StringBuilder();for (int i = 0; i < s.Length; i++){char ch = s[i];if (i > 0){sb.Append(' ');}if (ch < 128){sb.Append(ch);}else{if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END){sb.Append("H:");}else if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END){sb.Append("L:");}else if (ch > UNI_SUR_LOW_END){if (ch == 0xffff){sb.Append("F:");}else{sb.Append("E:");}}sb.Append("0x" + ((short)ch).ToString("X"));}}return sb.ToString();}
