utf-8编码问题
数据推动力 2005-02-17 02:14:22 我看了一些以前的帖子,也是关于UTF-8的
我常常看到有这个一段代码:
public String toUTF(String str) throws IOException
{
str = new String(str.getBytes("gb2312"),"ISO-8859-1");
return str;
}
public String toGB(String str) throws IOException
{
str = new String(str.getBytes("ISO-8859-1"),"gb2312");
return str;
}
我不太明白的是 str = new String(str.getBytes("gb2312"),"ISO-8859-1");
public byte[] getBytes(String charsetName) throws UnsupportedEncodingException
"charsetName"中并没有"gb2312",这个项啊,我看了那个java.sun.com中写道,只有
US-ASCII ISO-8859-1 UTF-8 UTF-16BE UTF-16LE UTF-16 几个啊,难道是我看走眼了吗?
疑惑中....
谢谢.