Here you can find the source of toUnicode(String str)
public static String toUnicode(String str)
//package com.java2s; public class Main { public static String toUnicode(String str) { String as[] = new String[str.length()]; String s1 = ""; for (int i = 0; i < str.length(); i++) { int v = str.charAt(i); if (v >= 19968 && v <= 171941) { as[i] = Integer.toHexString(str.charAt(i) & 0xffff); s1 = s1 + "\\u" + as[i]; } else { s1 = s1 + str.charAt(i); }/* w w w .j a v a2 s. c o m*/ } return s1; } }