String codification to Twitter

Posted by Miguel Ribeiro on Stack Overflow See other posts from Stack Overflow or by Miguel Ribeiro
Published on 2010-05-30T17:45:11Z Indexed on 2010/05/30 23:32 UTC
Read the original article Hit count: 270

I'm developing a program that sends tweets. I have this piece of code:

StringBuilder sb = new StringBuilder("Recomendo ");
    sb.append(lblName.getText());
    sb.append(" no canal "+lblCanal.getText());

    sb.append(" no dia "+date[2]+"/"+date[1]+"/"+date[0]);
    sb.append(" às "+time[0]+"h"+time[1]);

    byte[] defaultStrBytes = sb.toString().getBytes("ISO-8859-1");
    String encodedString = new String(defaultStrBytes, "UTF-8");

But When I send it to tweet I get the "?" symbol or other strage characters because of the accents like "à" . I've also tried with only

String encodedString = new String(sb.toString().getBytes(), "UTF-8"); //also tried with ISO-8859-1

but the problem remains...

© Stack Overflow or respective owner

Related posts about encoding

Related posts about twitter