Here you can find the source of toHexString(String s)
public static String toHexString(String s)
//package com.java2s; public class Main { public static final int UNI_SUR_HIGH_START = 0xD800; public static final int UNI_SUR_HIGH_END = 0xDBFF; public static final int UNI_SUR_LOW_START = 0xDC00; public static final int UNI_SUR_LOW_END = 0xDFFF; 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(' '); }/*www . ja va2 s. c om*/ 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" + Integer.toHexString(ch)); } } return sb.toString(); } }