Java et unicode

Résolu/Fermé
faico Messages postés 9 Date d'inscription lundi 1 août 2005 Statut Membre Dernière intervention 17 mars 2006 - 14 mars 2006 à 22:29
Twinuts Messages postés 5375 Date d'inscription dimanche 4 mai 2003 Statut Modérateur Dernière intervention 14 juin 2023 - 15 mars 2006 à 00:11
Salam : paix(en arabe)

Je souhaite ouvrire un fichier texte codé en UTF-8 avec mon aplli JAVA mais le probléme que JAVA utilise UTF-16.

Alors si vous avez une foction qui me transforme les octets que
je recupere appartir du fichier en UTF-16 elle sera la bienvenue
.Paceque j'ai du mal à ecrire une (les char sont codés soit sur 1,2 ou
3 octets cela me fait mal en tete) et il n'y a pas bcp de temp .

Et merci d'avance .

1 réponse

Twinuts Messages postés 5375 Date d'inscription dimanche 4 mai 2003 Statut Modérateur Dernière intervention 14 juin 2023 111
15 mars 2006 à 00:11
Salut,



essaye avec ca


String


public String(byte[] bytes,
String charsetName)
throws UnsupportedEncodingException



Constructs a new <tt>String</tt> by decoding the specified array of
bytes using the specified charset. The length of the new
<tt>String</tt> is a function of the charset, and hence may not be equal
to the length of the byte array.

The behavior of this constructor when the given bytes are not valid
in the given charset is unspecified. The
CharsetDecoder
class should be used when more control
over the decoding process is required.

* Parameters: :
bytes
- the bytes to be decoded into characters<dd>
charsetName
- the name of a supported
charset


* Throws: :
UnsupportedEncodingException
- If the named charset is not supported * Since: : <dd>JDK1.1


WORA
3
Rejoignez-nous