Here you can find the source of unicodeEscape(String s)
private static String unicodeEscape(String s)
//package com.java2s; public class Main { private static String unicodeEscape(String s) { StringBuilder sb = new StringBuilder(); boolean first = false; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (checkTurkish(c)) { sb.append(c);//from w w w . j a v a 2 s . c o m } else { if (checkAscii(c)) { sb.append(c); } else { if (!first) { sb.append(""); } } first = !first; } } return sb.toString(); } public static boolean checkTurkish(char c) { if (!(c == '\u011E' || c == '\u011F' || c == '\u015E' || c == '\u015F' || c == '\u0130' || c == '\u0131' || c == '\u00DC' || c == '\u00FC' || c == '\u00C7' || c == '\u00E7' || c == '\u00D6' || c == '\u00F6')) { return false; } return true; } public static boolean checkAscii(char c) { int hv = Integer.parseInt(Integer.toString(c)); if (hv < 32 || hv > 126) { return false; } return true; } }