使用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?

It is quite straightforward to do the replacement yourself:

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