Code ASCII java

Résolu/Fermé
nour_master Messages postés 10 Date d'inscription mardi 11 novembre 2008 Statut Membre Dernière intervention 17 décembre 2008 - 12 nov. 2008 à 11:48
choubaka Messages postés 39375 Date d'inscription jeudi 4 avril 2002 Statut Modérateur Dernière intervention 14 avril 2024 - 13 nov. 2008 à 23:08
Bonjour,
je cherche une methode java qui permet de retournet la chaine binaire coresponante a une chaine de caractere
A voir également:

2 réponses

choubaka Messages postés 39375 Date d'inscription jeudi 4 avril 2002 Statut Modérateur Dernière intervention 14 avril 2024 2 100
12 nov. 2008 à 15:46
Salut

il y a la méthode ci dessous de l'objet String

getBytes()
Convert this String into bytes according to the platform's default character encoding, storing the result into a new byte array.
0
nour_master Messages postés 10 Date d'inscription mardi 11 novembre 2008 Statut Membre Dernière intervention 17 décembre 2008 2
13 nov. 2008 à 13:26
merci la methode que vous m'avez indiquée retourne bien le code binaire. mais le pb et qu'elle me donne un code sue 7 bits seulement ,moi je cherche a avoir le code binaire sur 8 bits si vous avez une proposision a me faire ?
merci encord
0
choubaka Messages postés 39375 Date d'inscription jeudi 4 avril 2002 Statut Modérateur Dernière intervention 14 avril 2024 2 100
13 nov. 2008 à 23:08
salut

suivant ce lien

http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc

si tu regardes bien, il y a une remarque concernant la machine virtuelle java

"Every instance of the Java virtual machine has a default character encoding. The default encoding is determined during virtual-machine startup and typically depends upon the locale and encoding being used by the underlying operating system."

en fait, tu dois vérifier ceci

 Every implementation of the Java platform is required to support the following character encodings. Consult the release documentation for your implementation to see if any other encodings are supported.

    US-ASCII 	Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the Unicode character set
    ISO-8859-1   	ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1
    UTF-8 	Eight-bit Unicode Transformation Format
    UTF-16BE 	Sixteen-bit Unicode Transformation Format, big-endian byte order
    UTF-16LE 	Sixteen-bit Unicode Transformation Format, little-endian byte order
    UTF-16 	Sixteen-bit Unicode Transformation Format, byte order specified by a mandatory initial byte-order mark (either order accepted on input, big-endian used on output)


par défaut, c'est le US-ASCII qui est implémenté, tu dois modifier les paramètre de ta machine virtuelle et mettre l'UTF-8 si tu veux du 8 bits

0