String fname="%e6%8e%88%e6%9d%832"; url转码成中文
2016-08-12 10:05
344 查看
http://tool.chinaz.com/tools/urlencode.aspx 今天同事遇到的,如果是对方ecode,我直接decode就行,
知道对方怎么编码我们就能知道怎么解码了
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
public class test {
public static void main(String[] args) {
String fname=""+"&K17&"+"&lsSZVAR_KJQJ="+"&K18&"+"&lsS%E5%8F%96%E6%95%B0%E4%BC%9A%E8%AE%A1%E5%B9%B4%E5%BA%A6%EF%BC%9A="+"&K19&"+"&lsS%E5%8F%96%E6%95%B0%E4%BC%9A%E8%AE%A1%E6%9C%9F%E9%97%B4%EF%BC%9A="+"&K20&"+"&lsS%E4%BC%9A%E8%AE%A1%E5%B9%B4%E5%BA%A6="+"&K21&"+"&lsS%E4%BC%9A%E8%AE%A1%E6%9C%9F%E9%97%B4=&K22";
//将utf-8格式的中文转换成URL编码
//将URL编码的字符串转换成utf-8格式的中文
try {
String decodeFName = URLDecoder.decode(fname, "utf-8");
System.out.println(decodeFName);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
知道对方怎么编码我们就能知道怎么解码了
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
public class test {
public static void main(String[] args) {
String fname=""+"&K17&"+"&lsSZVAR_KJQJ="+"&K18&"+"&lsS%E5%8F%96%E6%95%B0%E4%BC%9A%E8%AE%A1%E5%B9%B4%E5%BA%A6%EF%BC%9A="+"&K19&"+"&lsS%E5%8F%96%E6%95%B0%E4%BC%9A%E8%AE%A1%E6%9C%9F%E9%97%B4%EF%BC%9A="+"&K20&"+"&lsS%E4%BC%9A%E8%AE%A1%E5%B9%B4%E5%BA%A6="+"&K21&"+"&lsS%E4%BC%9A%E8%AE%A1%E6%9C%9F%E9%97%B4=&K22";
//将utf-8格式的中文转换成URL编码
//将URL编码的字符串转换成utf-8格式的中文
try {
String decodeFName = URLDecoder.decode(fname, "utf-8");
System.out.println(decodeFName);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
相关文章推荐
- 【Python开发】Url中文字符时记得转码edcode("utf-8")
- Escape 解决中文乱码(URLDecoder: Illegal hex characters in escape (%) pattern - For input string: "u6")
- 解决var url="xxx&参数名="+“中文参数”; 传到后台根据String x = request.getParameter("中文参数名");乱码问题
- 利用Gate进行中文信息抽取时 不能识别Token.string=="中文"的问题
- 关于String转码成URL遇到的问题
- 远程读取中文网页内容并显示, keyword: html, stringWithContentsOfURL encoding
- .NET中url参数的编码和转码…【Server.UrlDecode(""),Server.UrlDecode("")】
- 编码 -- char 1= '中' 2 byte, 中文string a="中" 3字节问题
- Lua中url的中文转码
- Url中文传值乱码、编码转码问题总结
- load(url)与loadXML(xml/string)【ActiveXObject("Microsoft.XMLDOM")】
- PHP获取当前url路径的函数及服务器变量:$_SERVER["QUERY_STRING"],$_SERVER["REQUEST_URI"],$_SERVER["SCRIPT_NAME"],$_SER
- java中Url中文参数转码解决方案
- 关于faultString = "Security error accessing url" 问题解决总结
- Request.Query["xxx"] 与Request.Url.OriginalString
- url使用get方式提交时,js中文转码
- js java中文转码 适用于用url传递中文参数
- PHP获取当前url路径的函数及服务器变量:$_SERVER["QUERY_STRING"],$_SERVER["REQUEST_URI"],$_SERVER["SCRIPT_NAME"],$_SERVER["PHP_SELF"]
- 远程读取中文网页内容并显示, keyword: html, stringWithContentsOfURL encoding
- 浏览器地址传中文解决方法 URLEncoder.encode(str,"编码") new URLDecoder().decode(str,"编码")