salut je débarque
mon pb est déjà résolu mais j'ai pas compris pourquoi !
si qqn peut m'aider a elucider ce mystere...
soit "row" une String encodée en UTF-8
je veux l'afficher dans la sortie std sans pb d'accents
System.out.println(new String(row.getBytes(),"ISO-8859-1"));
=> marche pas
(pourtant, cette solution vient de ce forum)
System.out.println(new String(row.getBytes("UTF-8"),"ISO-8859-1"));
=> marche pas non plus
System.out.println(new String(row.getBytes("ISO-8859-1"),"UTF-8"));
=> marche !
System.out.println(new String(row.getBytes("ISO-8859-1")));
=> marche pas
javadoc String dit :
1)
public byte[] getBytes(String charsetName)
throws UnsupportedEncodingException
Encodes this String into a sequence of bytes using the named charset, storing the result into a new byte array.
=> ok, cela justifie "getBytes("ISO-8859-1")"
2)
public String(byte[] bytes,
String charsetName)
throws UnsupportedEncodingException
Constructs a new String by decoding the specified array of bytes using the specified charset.
=> pourquoi diable a-t-on besoin de cela puisque la chaine est deja réencodée avec getBytes("ISO-8859-1") ?
chui paumé
ce doit etre la fatigue
desolé d'avance si c le k
Partager