Java Unicode Create toUnicode(String str)

Here you can find the source of toUnicode(String str)

Description

to Unicode

License

Apache License

Declaration

public static String toUnicode(String str) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String toUnicode(String str) {
        char[] arChar = str.toCharArray();
        int iValue = 0;
        String uStr = "";
        for (int i = 0; i < arChar.length; i++) {
            iValue = (int) str.charAt(i);
            if (iValue <= 256) {
                // uStr+="& "+Integer.toHexString(iValue)+";";
                uStr += "\\" + Integer.toHexString(iValue);
            } else {
                // uStr+="&#x"+Integer.toHexString(iValue)+";";
                uStr += "\\u" + Integer.toHexString(iValue);
            }/*  ww w .  j a  va2  s. co  m*/
        }
        return uStr;
    }
}

Related

  1. toUnicode(String original)
  2. toUnicode(String s)
  3. toUnicode(String source)
  4. toUnicode(String str)
  5. toUnicode(String str)
  6. toUnicode(String str)
  7. toUnicode(String string)
  8. toUnicode(String strText)
  9. toUnicode(String text)