如何在 Java 中将 TIS-620 字符串转换为 UTF-8 字符串? [英] How to convert TIS-620 string to UTF-8 string in Java?
本文介绍了如何在 Java 中将 TIS-620 字符串转换为 UTF-8 字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 Java 中将 TIS-620(扩展的 ASCII 泰语字符代码页)字符串转换为 UTF-8 字符串?
How do I convert TIS-620 (the extended ASCII Thai Character code page) string to UTF-8 string in Java?
推荐答案
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 放在类路径中以支持 TIS620 编码.
Also, you might need to put charsets.jar on your classpath to support the TIS620 encoding.
这篇关于如何在 Java 中将 TIS-620 字符串转换为 UTF-8 字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文