Here you can find the source of toUnicode(String strText)
public static String toUnicode(String strText) throws UnsupportedEncodingException
//package com.java2s; /**// w w w . j a v a 2 s. co m * Copyright (C) 2002-2005 WUZEWEN. All rights reserved. * WUZEWEN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ import java.io.UnsupportedEncodingException; public class Main { public static String toUnicode(String strText) throws UnsupportedEncodingException { char c; String strRet = ""; int intAsc; String strHex; for (int i = 0; i < strText.length(); i++) { c = strText.charAt(i); intAsc = (int) c; // System.out.println(i+ " intAsc ss="+intAsc); if (intAsc > 128) { strHex = Integer.toHexString(intAsc); strRet = strRet + "\\u" + strHex.toUpperCase(); //&#x } else { strHex = Integer.toHexString(intAsc); strRet = strRet + "\\u00" + strHex.toUpperCase(); //&#x } } return strRet; } }