我阅读了参考问题urlencode vs rawurlencode?的内容,这表明我应该使用rawurlencode
。
例如:
如果与其他系统的互操作性很重要,则使用rawurlencode似乎是可行的选择。
但为什么会有urlencode
的发明呢?这是否意味着此函数无用?
我阅读了参考问题urlencode vs rawurlencode?的内容,这表明我应该使用rawurlencode
。
例如:
如果与其他系统的互操作性很重要,则使用rawurlencode似乎是可行的选择。
但为什么会有urlencode
的发明呢?这是否意味着此函数无用?
这要看你需要什么。它们之间的一个主要区别当然是它们编码的标准,但也会涉及到空格。
urlencode
的编码方式与表单数据的编码方式相同。
urlencode
将空格编码为加号(+
)符号,而 rawurlencode
则将其编码为 %20
。
因此,在处理表单数据时,urlencode 是首选(因为表单将空格编码为 + 符号)。否则,我认为用 rawurlencode 更加明智。
例如,如果你想模仿通过 URL 提交的表单数据,那么就应该使用 urlencode。
rawurlencode
会有什么问题? - Istiaque Ahmed