Code ASCII java

Résolu
nour_master -  
choubaka Messages postés 5535 Date d'inscription   Statut Modérateur Dernière intervention   -
Bonjour,
je cherche une methode java qui permet de retournet la chaine binaire coresponante a une chaine de caractere
Configuration: Windows XP
Internet Explorer 6.0

2 réponses

  1. choubaka Messages postés 5535 Date d'inscription   Statut Modérateur Dernière intervention   2 113
     
    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
    1. nour_master
       
      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
  2. choubaka Messages postés 5535 Date d'inscription   Statut Modérateur Dernière intervention   2 113
     
    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