Chaîne binaire et vice versa: ASCII étendu

Je veux convertir une Chaîne binaire en le mettant dans un tableau d'octets ( String.getBytes[] ), puis magasin de la chaîne binaire pour chaque octet (Integer.toBinaryString(bytearray)) dans une Chaîne de caractères[]. Ensuite, je veux convertir un retour à la normale de la Chaîne via Byte.parseByte(stringarray[i], 2). Cela fonctionne très bien pour le standard ASCII Table, mais pas pour l'étendue. Par exemple, un A me donne 1000001, mais un Ä retourne

11111111111111111111111111000011
11111111111111111111111110000100

Toutes les idées comment gérer cela?

public class BinString {
    public static void main(String args[]) {
        String s = "ä";
        System.out.println(binToString(stringToBin(s)));

    }

    public static String[] stringToBin(String s) {
        System.out.println("Converting: " + s);
        byte[] b = s.getBytes();
        String[] sa = new String[s.getBytes().length];
        for (int i = 0; i < b.length; i++) {
            sa[i] = Integer.toBinaryString(b[i] & 0xFF);
        }
        return sa;
    }

    public static String binToString(String[] strar) {
        byte[] bar = new byte[strar.length];
        for (int i = 0; i < strar.length; i++) {
            bar[i] = Byte.parseByte(strar[i], 2);
            System.out.println(Byte.parseByte(strar[i], 2));

        }
        String s = new String(bar);
        return s;
    }

}
InformationsquelleAutor anonymous001 | 2011-04-04