Java Native to Unicode native2Unicode(String s)

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

Description

native Unicode

License

Open Source License

Declaration

static public String native2Unicode(String s) 

Method Source Code

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

public class Main {
    static public String native2Unicode(String s) {
        char c;/*from  w w w.  j a  va  2  s.  c  o m*/
        int j = 0;
        if (s == null || s.length() == 0) {
            return null;
        }
        byte[] buffer = new byte[s.length()];
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) >= 0x100) {
                c = s.charAt(i);
                byte[] buf = ("" + c).getBytes();
                buffer[j++] = buf[0];
                buffer[j++] = buf[1];
            } else {
                buffer[j++] = (byte) s.charAt(i);
            }
        }
        return new String(buffer, 0, j);
    }
}

Related

  1. native2unicode(String s)