gbk转utf-8问题,看了好多帖但均没有很好的答案,请帮帮忙, 我从一个只支持gbk编码的插件中得到一个串,但我的项目是用utf-8的,所以显示的中文乱码,我该如何做才能显示汉字呢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 源码如下,这个插件只支持GBK格式编码,我的项目是utf-8的,我调用的是他的方法得到字符串,应该也是gbk的吧,public static void main(String[] args){ String name=null; String password=null; String message = null; try {name = new String("是否".getBytes("UTF-8"),"GBK");password = new String("11111".getBytes("UTF-8"),"GBK");message = new String("发送短信测试".getBytes("UTF-8"),"GBK");} catch (UnsupportedEncodingException e1) {e1.printStackTrace();} Sender sms = new Sender(name,password);String returnCode = sms.massSend("13633618954",message ,"时间","特服代码");String encode = null;try{encode = new String(returnCode.getBytes("GBK"),"UTF-8");}catch(Exception e){e.printStackTrace();}System.out.println(encode); } 你的项目用UTF-8没关系啊,只要你项目所在的平台支持GBK就可以了:try {name = new String("是否".getBytes("iso8859-1"),"GBK");password = new String("11111".getBytes("iso8859-1"),"GBK");message = new String("发送短信测试".getBytes("iso8859-1"),"GBK");} catch (UnsupportedEncodingException e1) {e1.printStackTrace();}//这里就是你说的插件返回的值? Sender sms = new Sender(name,password);String returnCode = sms.massSend("13633618954",message ,new String("时间".getBytes("iso8859-1"),"GBK"),new String("特服代码".getBytes("iso8859-1"),"GBK"));String encode = null;try{//这里是多余的吧?encode = new String(returnCode.getBytes("iso8859-1"),"GBK");}catch(Exception e){e.printStackTrace();}System.out.println(encode); 求助关于在java中播放声音的问题 请教一个文件内容替换的问题 java 光标 EventDispatchThread 是个什么东东,我调试时为什么经常进入这个类。。。。 Object.class的问题 新手求救,如何实现网页上显示在线用户和网页统计点击数 有没有人使用JCreator?为什么增加了JSP的语法,在编辑JSP文件时,对象点不开方法??? 怎样令程序退出时执行多个操作,比如退出时关闭数据库连接 JCreate Pro编译后不能正确执行时的问题? 初来贵页,请大家多多关照 lz这种情况还有没有更高效的处理方法? 急!急!请高手指点哈,发送一条短信,是否在两分钟内回复
public static void main(String[] args){
String name=null;
String password=null;
String message = null; try {
name = new String("是否".getBytes("UTF-8"),"GBK");
password = new String("11111".getBytes("UTF-8"),"GBK");
message = new String("发送短信测试".getBytes("UTF-8"),"GBK");
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
Sender sms = new Sender(name,password);String returnCode = sms.massSend("13633618954",message ,"时间","特服代码");
String encode = null;
try{
encode = new String(returnCode.getBytes("GBK"),"UTF-8");
}catch(Exception e){
e.printStackTrace();
}
System.out.println(encode);
}
name = new String("是否".getBytes("iso8859-1"),"GBK");
password = new String("11111".getBytes("iso8859-1"),"GBK");
message = new String("发送短信测试".getBytes("iso8859-1"),"GBK");
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
//这里就是你说的插件返回的值?
Sender sms = new Sender(name,password);
String returnCode = sms.massSend("13633618954",message ,
new String("时间".getBytes("iso8859-1"),"GBK"),
new String("特服代码".getBytes("iso8859-1"),"GBK"));String encode = null;
try{
//这里是多余的吧?
encode = new String(returnCode.getBytes("iso8859-1"),"GBK");
}catch(Exception e){
e.printStackTrace();
}
System.out.println(encode);