展开全部
Javascript 中的 decodeURI/decodeURIComponent,Java中的java.net.URLDecoder类的decode方法提供了相近62616964757a686964616fe4b893e5b19e31333337613736的功能,但又有一些微妙的不同:var URLDecoder = Java.type("java.net.URLDecoder");
var URLEncoder = Java.type("java.net.URLEncoder");
var url = "
中文";
var s1 = encodeURI(url);
var s2 = encodeURIComponent(url);
var s3 = URLEncoder.encode(url, "UTF-8");
print(s1);
print(s2);
print(s3);
print("-------------")
print(decodeURI(s1));
print(decodeURI(s2));
print(decodeURI(s3));
print("-------------")
print(decodeURIComponent(s1));
print(decodeURIComponent(s2));
print(decodeURIComponent(s3));
print("-------------")
print(URLDecoder.decode(s1, "UTF-8"));
print(URLDecoder.decode(s2, "UTF-8"));
print(URLDecoder.decode(s3, "UTF-8"));使用JDK8的jjs.exe运行上面这段代码,结果如下:D:\Temp>j:\share\jdk8\bin\jjs.exe url.js
http%3A%2F%2Fwww.example.com%2Fstring%20with%20%2B%20and%20%3F%20and%20%26%20and%20%E4%B8%AD%E6%96%87
http%3A%2F%2Fwww.example.com%2Fstring+with+%2B+and+%3F+and+%26+and+%E4%B8%AD%E6%96%87
-------------
中文
http%3A%2F%2Fwww.example.com%2Fstring with %2B and %3F and %26 and 中文
http%3A%2F%2Fwww.example.com%2Fstring+with+%2B+and+%3F+and+%26+and+中文
-------------
中文
中文
中文
-------------
中文
中文
中文