duannao1920 2014-08-06 17:24
浏览 29

使用plus编码空格的URL编码

I have an application that needs to sign form data before it is sent to server. In the signing method, I have to escape all form input values with javascript, sign them and then send the signed data to server for cross matching. The remote server is escaping form data in a way that it enocodes all spaces with plus.

So if my form data is:

this is test :)

The encoded output should be

this+is+test+%3A)

But I tested javascripts encodeURIComponent, encodeURI and escape. All of them gives me the following output:

this%20is%20test%20%3A)

Any ideas which function is right for this?

  • 写回答

1条回答 默认 最新

  • duanfu3390 2014-08-06 17:32
    关注

    It is quite straightforward to do the replacement yourself:

    var encoded = escape(s).replace(/%20/g, "+");
    alert(encoded); // outputs "this+is+test+%3A)"
    
    评论

报告相同问题?

悬赏问题

  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗