[英]Does php urlencode the same with java urlencode?
In PHP: 在PHP中:
php -r "echo urlencode('["IM"]'); "
The result is %5BIM%5D
结果是
%5BIM%5D
But in java 但在java中
String text = URLEncoder.encode('["IM"]',"UTF-8");
System.out.println("text" + text);
The result is text%5B%22IM%22%5D
结果是
text%5B%22IM%22%5D
What's the different between these two functions? 这两个功能有什么不同? How can I implement a java code to complete the same function of php?
如何实现java代码来完成相同的php功能?
String text = URLEncoder.encode('[IM]',"UTF-8");
System.out.println("text" + text);
gives %5BIM%5D
给出
%5BIM%5D
echo urlencode('["IM"]');
gives %5B%22IM%22%5D
给出
%5B%22IM%22%5D
echo urlencode('[IM]');
gives %5BIM%5D
给出
%5BIM%5D
echo urlencode('[\"IM\"]');
gives %5B%5C%22IM%5C%22%5D
得到
%5B%5C%22IM%5C%22%5D
试图逃避内部qoutes
php -r "echo urlencode('[\"IM\"]'); "
php -r "echo urlencode('["IM"]'); "
The result is %5BIM%5D because the function urlencode is actually only taking the string [IM]
as its input. 结果是%5BIM%5D,因为函数urlencode实际上只是将字符串
[IM]
作为其输入。 while in java 而在java中
String text = URLEncoder.encode('["IM"]',"UTF-8");
The string being passed is actually: ["IM"]
which generates the value %22
which is encode-string for "
the quote mark. 传递的字符串实际上是:
["IM"]
,它产生值%22
,它是"
引号"
的编码字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.