Here you can find the source of toUnicodeString(String s)
public static String toUnicodeString(String s)
//package com.java2s; //License from project: Apache License public class Main { public static String toUnicodeString(String s) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c >= 0 && c <= 255) { sb.append(c);/*from w ww . ja va2 s . co m*/ } else { sb.append("\\u" + Integer.toHexString(c)); } } return sb.toString(); } }