Java Unicode Create toUnicode(String input)

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

Description

to Unicode

License

Open Source License

Declaration

public static String toUnicode(String input) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String toUnicode(String input) {
        String output = "";
        try {// w ww.j  a  v  a2s.c o m
            if (input != null && input.length() > 0) {
                for (int i = 0; i < input.length(); i++) {
                    output += toUnicode(input.charAt(i));
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return output;
    }

    private static char toUnicode(char input) {
        if (input == 168) {
            return 1025;
        } else if (input == 170) {
            return 1256;
        } else if (input == 175) {
            return 1198;
        } else if (input == 184) {
            return 1105;
        } else if (input == 186) {
            return 1257;
        } else if (input == 191) {
            return 1199;
        } /* else if(input == 1028) {
          return 1256;
          } else if(input == 1031) {
          return 1198;
          } else if(input == 1108) {
          return 1257;
          } else if(input == 1111) {
          return 1199;
          } */else if (192 <= input && input <= 255) {
            return (char) (input + 848);
        } else {
            return input;
        }
    }
}

Related

  1. getUnicodeString(byte[] d, int length, int pos)
  2. getUnicodeText(Object text)
  3. toUnicode(char c)
  4. toUnicode(final String toUnicode, final boolean toLowerCase)
  5. toUnicode(String input)
  6. toUnicode(String input)
  7. toUnicode(String original)
  8. toUnicode(String s)
  9. toUnicode(String source)