Here you can find the source of stringToUnicode(String strText)
public static String stringToUnicode(String strText)
//package com.java2s; public class Main { public static String stringToUnicode(String strText) { char c;// w w w . ja v a 2 s . co m String strRet = ""; int intAsc; String strHex; for (int i = 0; i < strText.length(); i++) { c = strText.charAt(i); intAsc = (int) c; strHex = Integer.toHexString(intAsc); if (intAsc > 128) { strRet += "\\u" + strHex; } else { strRet += "\\u00" + strHex; } } return strRet; } }