Android Unicode Convert unicodeEscape(String s)

Here you can find the source of unicodeEscape(String s)

Description

unicode Escape

Declaration

private static String unicodeEscape(String s) 

Method Source Code

//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;
    }
}

Related

  1. convertToUnicodeByteArray(String s)
  2. convertToUnicode(byte[] b, boolean includesNull)
  3. stringToUnicode(String strText)
  4. unicode2han3last_direct(Character c)
  5. unicode2han_str(String str)
  6. getEmojiByUnicode(int unicode)
  7. hiraganaToKatakana(byte[] b)