String codification to Twitter
- by Miguel Ribeiro
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...