2008-10-29 9 views

Répondre

1
import java.nio.ByteBuffer 
import java.nio.CharBuffer 

....

public static ByteBuffer toByteBuffer(String content, String encode) { 
     Charset charset = Charset.forName(encode); 
     ByteBuffer bb = charset.encode(content); 
     return bb; 
    } 

passe comme argument encode "UTF-8"

+0

ne marche toujours pas bien !!! – user21508

1
private byte[] convertTis620ToUTF8(byte[] encoded) 
{ 
    try 
    { 
     String theString = new String(encoded, "TIS620"); 
     return theString.getBytes("UTF-8"); 
    } 
    catch(UnsupportedEncodingException uee) 
    { 
     /* Didn't work out */ 
    } 
} 

... 

byte[] utf8 = convertTis620ToUTF8(tis620); 

, vous pourriez aussi avoir besoin de mettre charsets.jar sur votre classpath pour soutenir la Encodage TIS620.

Questions connexes