dongzhuo5425 2011-06-06 18:15
浏览 56

URLEncode在ASP classic和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 are 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.

  • 写回答

1条回答 默认 最新

  • dongshi1914 2011-06-06 18:19
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算