décoder la chaîne encodée en utf-8 format à android

J'ai une chaîne qui vient via un xml , et c'est le texte en allemand. Les caractères qui sont spécifiques en allemand sont encodés via le format UTF-8. Avant d'afficher la chaîne j'ai besoin de le décoder.

J'ai essayé ce qui suit:

try {
    BufferedReader in = new BufferedReader(
            new InputStreamReader(
                    new ByteArrayInputStream(nodevalue.getBytes()), "UTF8"));
    event.attributes.put("title", in.readLine());
} catch (UnsupportedEncodingException e) {
    //TODO Auto-generated catch block
    e.printStackTrace();
} catch (IOException e) {
    //TODO Auto-generated catch block
    e.printStackTrace();
}

J'ai aussi essayé ceci:

try {
    event.attributes.put("title", URLDecoder.decode(nodevalue, "UTF-8"));
} catch (UnsupportedEncodingException e) {
    //TODO Auto-generated catch block
    e.printStackTrace();
}

Aucun d'entre eux travaillent. Comment décoder la chaîne allemande

vous en remercie d'avance.

UDPDATE:

@Override
public void characters(char[] ch, int start, int length)
        throws SAXException {
    //TODO Auto-generated method stub
    super.characters(ch, start, length);
    if (nodename != null) {
        String nodevalue = String.copyValueOf(ch, 0, length);
        if (nodename.equals("startdat")) {
            if (event.attributes.get("eventid").equals("187")) {
            }
        }
        if (nodename.equals("startscreen")) {
            imageaddress = nodevalue;
        }
        else {
            if (nodename.equals("title")) {
                //try {
                //BufferedReader in = new BufferedReader(
                //new InputStreamReader(
                //new ByteArrayInputStream(nodevalue.getBytes()), "UTF8"));
                //event.attributes.put("title", in.readLine());
                //} catch (UnsupportedEncodingException e) {
                ////TODO Auto-generated catch block
                //e.printStackTrace();
                //} catch (IOException e) {
                ////TODO Auto-generated catch block
                //e.printStackTrace();
                //}
                //try {
                //event.attributes.put("title",
                //URLDecoder.decode(nodevalue, "UTF-8"));
                //} catch (UnsupportedEncodingException e) {
                ////TODO Auto-generated catch block
                //e.printStackTrace();
                //}
                event.attributes.put("title", StringEscapeUtils
                        .unescapeHtml(new String(ch, start, length).trim()));
            } else
                event.attributes.put(nodename, nodevalue);
        }
    }
}
Je ne pouvais pas trouver ce Q&quand j'en avais besoin. Donc j'ai retaged maintenant, j'espère que ce sera pop-up rapide la prochaine fois

OriginalL'auteur user590849 | 2011-04-29