Here you can find the source of native2ascii(String code)
public static String native2ascii(String code)
//package com.java2s; //License from project: Apache License public class Main { public static String native2ascii(String code) { char[] chars = code.toCharArray(); int charValue = 0; String result = ""; for (int i = 0; i < chars.length; i++) { charValue = (int) code.charAt(i); if (charValue <= 256) { // result += "& "+Integer.toHexString(charValue)+";"; result += "\\" + Integer.toHexString(charValue); } else { // result += "&#x"+Integer.toHexString(charValue)+";"; result += "\\u" + Integer.toHexString(charValue); }//from w w w . j a va2 s . c om } return result; } }