结论:urlencode 先比URLEncoder.encode多编码 “ * ” 符号,其他都保持一致

php urlencode 

  phpversion()>=5.3 will compliant with RFC 3986, while phpversion()<=5.2.7RC1 is not compliant with RFC 3986.

  参考 RFC3896 方式编码

  

返回字符串,此字符串中除了 -_. 之外的所有非字母数字字符都将被替换成百分号(%)后跟两位十六进制数,空格则编码为加号(+)。
此编码与 WWW 表单 POST 数据的编码方式是一样的,同时与 application/x-www-form-urlencoded 的媒体类型编码方式一样。
由于历史原因,此编码在将空格编码为加号(+)方面与 » RFC3896 编码(参见 rawurlencode())不同。

php并没有完全按照 rfc3896编码,符号【~】在标准中是不用编码,但是他也编码了。

所以最终的未编码的字符列表为 [-], [_], [.],如同其文档中描述的一样

java URLEncoder.encode

  参考 RFC2396 方式编码

  但是由于ie浏览器编码了除  "-", "_", ".", "*" 之外的字符,java采用了和IE一样的编码列表,

  所以最终的未编码的字符列表为 [-], [_], [.], [*]

  

The list of characters that are not encoded has been
determined as follows: RFC states:
-----
Data characters that are allowed in a URI but do not have a
reserved purpose are called unreserved. These include upper
and lower case letters, decimal digits, and a limited set of
punctuation marks and symbols. unreserved = alphanum | mark mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")" Unreserved characters can be escaped without changing the
semantics of the URI, but this should not be done unless the
URI is being used in a context that does not allow the
unescaped character to appear.
----- It appears that both Netscape and Internet Explorer escape
all special characters from this list with the exception
of "-", "_", ".", "*". While it is not clear why they are
escaping the other characters, perhaps it is safest to
assume that there might be contexts in which the others
are unsafe if not escaped. Therefore, we will use the same
list. It is also noteworthy that this is consistent with
O'Reilly's "HTML: The Definitive Guide" (page ). As a last note, Intenet Explorer does not encode the "@"
character which is clearly not unreserved according to the
RFC. We are being consistent with the RFC in this matter,
as is Netscape.

History of related RFCs:

RFC 1738 section 2.2
only alphanumerics, the special characters "$-_.+!*'(),", and
reserved characters used for their reserved purposes may be used
unencoded within a URL.

RFC 2396 section 2.3
unreserved = alphanum | mark
mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"

RFC 2732 section 3
(3) Add "[" and "]" to the set of 'reserved' characters:

RFC 3986 section 2.3
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"

RFC 3987 section 2.2
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"

php urlencode vs java URLEncoder.encode的更多相关文章

  1. java URLEncoder 和Base64.encode()

    参考: http://www.360doc.com/content/10/1103/12/1485725_66213001.shtml (URLEncode) http://blog.csdn.net ...

  2. 关于 web中 使用 java.net.URLEncoder.encode 要编码两次呢 , js的encodeURIComponent 同理

    因为在jsp中对中文进行了编码的时候用的是UTF-8的编码方式,而在servlet中调用request.getParameter();方法的时候使用服务器指定的原始编码格式(ISO-8859-1)自动 ...

  3. java中的URLEncoder.encode对应JS中用decodeURIComponent,js和java编码,解码

    用get请求传中文,经常搞到乱码,这几天搞搞这个东西,总结一下,以方便以后处理这类的问题. Java代码中的URLEncoder.encode方法和JS的encodeURIComponent功能差不多 ...

  4. 为什么java的web开发中URLEncoder.encode方法要为什么要调用两次

    一: 我们先看2个编码的情况 String name=java.net.URLEncoder.encode("测试", "UTF-8"); System.out ...

  5. 中文乱码在java中URLEncoder.encode方法要调用两次解决

    中文乱码在java中URLEncoder.encode方法要调用两次解决 一.场景: 1.我在客户端要通过get方式调用服务器端的url,将中文参数做utf-8编码,需要在js中两次的进行编码,服务器 ...

  6. 如何判断某String是否经过urlEncoder.encode过

    import java.util.BitSet; public class UrlEncoderUtils { private static BitSet dontNeedEncoding; stat ...

  7. URLEncoder.encode问题

    遇到java里的URLEncoder.encode方法编码后与javascript的encodeURIComponent方法的结果有点不一样,找了一下资料,原来URLEncoder实现的是HTML形式 ...

  8. URLEncoder.encode 和 URLDecoder.decode 处理url的特殊参数

    在使用 url 的 queryString 传递参数时,因为参数的值,被DES加密了,而加密得到的是 Base64的编码字符串,类似于: za4T8MHB/6mhmYgXB7IntyyOUL7Cl++ ...

  9. Java——URLEncoder和URLDecoder

    import java.net.URLDecoder; import java.net.URLEncoder; //========================================== ...

随机推荐

  1. Python多继承之MRO算法

    MRO即Method Resolution Order   方法解析顺序,它的提出主要是为了解决Python中多继承时,当父类存在同名函数时,二义性的问题 下面先看一个例子: import inspe ...

  2. loadrunner之运行方式:线程还是进程?

    loadrunner controller将使用驱动程序mmdrv运行Vuser. 用户可以在controller的run-time setting中选择Vuser的运行方式: 是多进程方式还是多线程 ...

  3. Java常用API——时间类

    前言:Java.util.*工具包中,包含了集合框架,旧集合类,事件模型,日期和时间设施,国际化和其他使用程序类 (字符串.随机数生成器和位数组) 一.日期类Date 1.概述 Date是一个薄包装类 ...

  4. CodeForces 1117C Magic Ship (循环节+二分答案)

    <题目链接> 题目大意: 给定起点和终点,某艘船想从起点走到终点,但是海面上会周期性的刮风,船在任何时候都能够向四个方向走,或者选择不走,船的真正行走路线是船的行走和风的走向叠加的,求船从 ...

  5. centos6.5安装/升级到python2.7

    https://www.cnblogs.com/harrymore/p/9024287.html

  6. 练习七 Procedure中使用DDL

    1 在存储过程中使用ddl语句有如下异常: create or replace procedure test_create_table (Table_Name in VARCHAR2, column_ ...

  7. Xamarin Essentials教程使用加速度传感器Accelerometer

    Xamarin Essentials教程使用加速度传感器Accelerometer   加速度传感器是一种能够测量加速度的传感器,用于检测设备状态的改变.在Xamarin中,如果开发者想要使用加速度传 ...

  8. 电脑用bat脚本给手机批量自动安装apk文件 autoInstall.bat

    ------创建这个文件autoInstall.bat 内容如下: @ECHO off @REM 将adb.exe添加到PATH中ECHO 初始化…@SET PATH=%PATH%;%CD%\Adb@ ...

  9. python3 词法拆分

    1.可以利用translate+string模块 2.可以利用jieba进行分词(结巴分词会分成词,但是我需要断句,所以这里不用) 3.利用python内置函数解决 仅仅只列出第3种方法,其他两种方法 ...

  10. LeetCode(283. 移动零)

    问题描述 给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序. 示例: 输入: [0,1,0,3,12] 输出: [1,3,12,0,0] 说明: 必须在原数 ...