2008-10-29 63 views

回答

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; 
    } 

通行證的編碼參數 「UTF-8」

+0

仍然沒有完全正確的工作! – user21508 2008-10-30 09:36:34

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); 

此外,你可能需要把charsets.jar在classpath支持TIS620編碼。

相關問題