看某编码方法是否支持,可以用编码方法从byte数组中创建字符串
请问怎么实现举个例子?
我用拿个编码方法?
byte[] temp1,temp2;
temp1 = yourstring.getBytes("8859-1");
temp2 = yourstring.getBytes("gb2312");
String compstring1,compstring2;
compstring1 = new String(temp1);
compstring2 = new String(temp2);
if(yourstring.equals(temp1))
{
//8859-1;
}
else
{
//gb2312;
}
可以吗
请问怎么实现举个例子?
我用拿个编码方法?
byte[] temp1,temp2;
temp1 = yourstring.getBytes("8859-1");
temp2 = yourstring.getBytes("gb2312");
String compstring1,compstring2;
compstring1 = new String(temp1);
compstring2 = new String(temp2);
if(yourstring.equals(temp1))
{
//8859-1;
}
else
{
//gb2312;
}
可以吗
temp2 = yourstring.getBytes("gb2312");
我的机器这两句出错...
测试了一下,好象是不行.if(yourstring.equals(temp1))
这句不行吧,String 和 byte[]不能比较吧!