Here you can find the source of charToString(char ch)
public static String charToString(char ch)
//package com.java2s; //License from project: LGPL public class Main { public static String charToString(char ch) { if (isAsciiPrintable(ch)) { return String.valueOf(ch); } else {//from w w w .ja va2 s. c o m StringBuilder buffer = new StringBuilder("\\u"); String hex = Integer.toHexString((int) ch); for (int i = 0; i < 4 - hex.length(); i++) { buffer.append('0'); } buffer.append(hex); return buffer.toString(); } } public static boolean isAsciiPrintable(char ch) { return ch >= 32 && ch < 127; } }