Here you can find the source of unicodeEncode(String s)
public static String unicodeEncode(String s)
//package com.java2s; //License from project: Apache License public class Main { /**/*from w ww.j a v a 2 s .c o m*/ * unicode encoding (for verbose mode) */ public static String unicodeEncode(String s) { StringBuilder buf = new StringBuilder(); for (int i = 0; i < s.length(); ++i) { char ch = s.charAt(i); if (ch >= '\u0080') { String st = Integer.toHexString(0x10000 + (int) ch); while (st.length() < 4) st = "0" + st; buf.append("\\u").append(st.subSequence(1, 5)); } else { buf.append(ch); } } return buf.toString(); } }