Java Unicode Create toUnicodeString(String s)

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

Description

to Unicode String

License

Apache License

Declaration

public static String toUnicodeString(String s) 

Method Source Code

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

public class Main {
    public static String toUnicodeString(String s) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c >= 0 && c <= 255) {
                sb.append(c);/*from   w ww  .  ja va2  s . co m*/
            } else {
                sb.append("\\u" + Integer.toHexString(c));
            }
        }
        return sb.toString();
    }
}

Related

  1. toUnicodeString(byte[] ba)
  2. toUnicodeString(byte[] data)
  3. toUnicodeString(char c)
  4. toUnicodeString(char[] chars)
  5. toUnicodeString(String baseString)
  6. toUnicodeString(String str)
  7. toUnicodeSymbols(String s)
  8. toUnicodeValue(char c)
  9. toUnicodeValue(char c)