0
如何將TIS-620(擴展ASCII泰文字符代碼頁)字符串轉換爲Java中的UTF-8字符串?如何將TIS-620字符串轉換爲Java中的UTF-8字符串?
如何將TIS-620(擴展ASCII泰文字符代碼頁)字符串轉換爲Java中的UTF-8字符串?如何將TIS-620字符串轉換爲Java中的UTF-8字符串?
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」
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編碼。
仍然沒有完全正確的工作! – user21508 2008-10-30 09:36:34