非中文系统下的汉字显示问题(涉及内码转换)
系统环境:日文2000S
开发环境:jdk1.4.1
前提条件:从数据库或者从文件中读出的汉字字符(已经经过UNICODE转换)。
问题:如何将此字符串以正常的中文形式显示在APPLET上或者dos console上呢?
写了如下一个测试代码,但是显示出来仍然是“??”,请高手指教。
class testStr
{
public static void main(String[] args)
{
String s="\u8fdb\u5ea6";//unicode编码,汉字是“进度”
byte[] bys1 = s.getBytes();
String str1=null;
try
{
str1 = new String(bys1,"gb2312");
}
catch(Exception e)
{
System.out.println("Error");
}
System.out.println("Hello World!"+ str1);
}
}