开发者

URLEncode return different value in ASP classic and PHP

I'm developing and application which must integrate with PayPal. To do so, it makes some call via API, and in these calls I have to pass some parameters that a开发者_如何学JAVAre URLEncoded. My problem is that I don't get it working because Server.URLEncode of classic asp returns me something strange.

See bellow:

@CODEPAGE="65001"    
Response.Charset = "UTF-8"
response.write(server.URLEncode("xxxx_1344559025_biz_api1.yy.com"))

Returns me this string: xxxx%5F1344559025%5Fbiz%5Fapi1%2Eyy%2Ecom

The same in PHP

echo(urlencode('xxxx_1344559025_biz_api1.yy.com'));

Returns me this string:xxxx_1344559025_biz_api1.yy.com

Both files are encoded in UTF-8, I do that on DreamWeaver with CTRL+J > title/encoding

Does anyone know why I get a so different answer in ASP classic and PHP?

Thanks in advance for any help.


The ASP version of URLEncode is just stricter than the PHP version.

Some characters, like the dot or the underscore do not absolutely need to be encoded (as opposed to the ampersand or the equals sign, which could break the query string if left unencoded).

I suppose for the reason of producing less "ugly" URLs, PHP leaves these characters unencoded, as they do no harm, while ASP stricly encodes everything that's not an ASCII alphanumeric.

In the end there will be no difference between the strings.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜