URL中的%...怎么转换成中文...

butnet 2006-06-06 12:31:52
URL中的%...怎么转换成中文...
谢谢!!!
String gbk=URLDecoder.decode("%E6%8E%A5%E5%8F%97%E7%9A%84%E6%96%87%E4%BB%B6.txt","UTF");
转换成的不对...
谢谢!!!
...全文
975 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
yingge 2006-06-06
  • 打赏
  • 举报
回复
String gbk=URLDecoder.decode("%E6%8E%A5%E5%8F%97%E7%9A%84%E6%96%87%E4%BB%B6.txt","UTF-8");
badboy19800808 2006-06-06
  • 打赏
  • 举报
回复
public static String gb2iso(String str) {
if (str != null) {
byte[] tmpbyte = null;
try {
tmpbyte = str.getBytes("GBK");
}
catch (Exception e) {
System.out.println("Error: Method: dbconn.gb2iso :" + e.getMessage());
}
try {
str = new String(tmpbyte, "ISO8859_1");
}
catch (Exception e) {
System.out.println("Error: Method: dbconn.gb2iso :" + e.getMessage());
}
}
else
str = "";
return str;
}


public static String iso2gb(String str) {
if (str != null) {
byte[] tmpbyte = null;
try {
tmpbyte = str.getBytes("ISO8859_1");
}
catch (Exception e) {
System.out.println("Error: Method: dbconn.iso2gb :" + e.getMessage());
}
try {
str = new String(tmpbyte, "GBK");
}
catch (Exception e) {
System.out.println("Error: Method: dbconn.gb2iso :" + e.getMessage());
}
}
else
str = "";
if (str == null)
str = "";
return str;
}
sheep219 2006-06-06
  • 打赏
  • 举报
回复
ding
cangwu_lee 2006-06-06
  • 打赏
  • 举报
回复
路过
zeq258 2006-06-06
  • 打赏
  • 举报
回复
接分
cnyxlxw 2006-06-06
  • 打赏
  • 举报
回复
mark!!
UnAgain 2006-06-06
  • 打赏
  • 举报
回复
mark
OnlyFor_love 2006-06-06
  • 打赏
  • 举报
回复
楼主你的方法是对的,正象 yingge(盼胖) 所写的,你在转码的时候把UTF-8写成UTF了
OnlyFor_love 2006-06-06
  • 打赏
  • 举报
回复
接受的文件.txt

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧