2008-10-29 196 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编码。

相关问题