Here you can find the source of unicodeEscape(Character ch)
public static final String unicodeEscape(Character ch)
//package com.java2s; /*/*from w ww. ja v a 2s. co m*/ * org.daisy.util (C) 2005-2008 Daisy Consortium * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ public class Main { /** * converts a Character to a java-style unicode escaped string */ public static final String unicodeEscape(Character ch) { return unicodeHexEscapeJava(ch.charValue()); } /** * converts each char of a string to java-style unicode escaped strings */ public static final String unicodeEscape(String string) { String ret = ""; char[] a = string.toCharArray(); for (int i = 0; i < a.length; i++) { ret = ret + unicodeHexEscapeJava(a[i]); ; } return ret; } /** * converts a char to a java-style unicode escaped string */ public static final String unicodeHexEscapeJava(char ch) { if (ch < 0x10) { return "\\u000" + Integer.toHexString(ch); } else if (ch < 0x100) { return "\\u00" + Integer.toHexString(ch); } else if (ch < 0x1000) { return "\\u0" + Integer.toHexString(ch); } return "\\u" + Integer.toHexString(ch); } }