请教,简单转码问题 ?

dui_cky 2011-08-24 08:57:38


from=厦门&to=上海

对应

from=%CF%C3%C3%C5&to=%C9%CF%BA%A3


请问 厦门 <--> %CF%C3%C3%C5& 这个是 什么码 ? 16进制 ? 还是什么别的 ? 知道的回答个,谢谢。
...全文
87 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
dui_cky 2011-08-25
  • 打赏
  • 举报
回复

public static String getValue(String str) {
StringBuilder value = new StringBuilder();
try {
byte[] buff = str.getBytes("GB2312");
for (int i = 0; i < buff.length; i++) {
value.append("%").append(Integer.toHexString(buff[i]).substring(6, 8).toUpperCase());
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return "";
}
return value.toString();
}
dui_cky 2011-08-25
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 goldenfish1919 的回复:]

Java code

public static void main(String[] args)throws Exception {
String str = "厦门上海";
byte[] buff = str.getBytes("GB2312");
for(int i=0;i<buff.length;i++){
Sys……
[/Quote]
正解。

感谢goldenfish1919和softroad 的回答.

softroad 2011-08-24
  • 打赏
  • 举报
回复
看不出来,js转码不过不是你那个
alert(encodeURI("from=厦门&to=上海"));直接转后台直接拿
若鱼1919 2011-08-24
  • 打赏
  • 举报
回复

public static void main(String[] args)throws Exception {
String str = "厦门上海";
byte[] buff = str.getBytes("GB2312");
for(int i=0;i<buff.length;i++){
System.out.println(Integer.toHexString(buff[i]));
}
}

62,614

社区成员

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

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