Sungguk Lim
Sungguk Lim

Reputation: 6228

is there any way to pass string contains '+' via the Querystring

I need to pass '+' via the QueryString.

some special character can be passed by using 'Encode' .. but '+'

I know the one solution, If I replace '+' with other character.

But it's not the perfect solution.

[edited]

well I used escape() javascript function to encode.

escape function can't encode + . is the another function to encode on javascript?

Upvotes: 1

Views: 176

Answers (4)

D'Arcy Rittich
D'Arcy Rittich

Reputation: 171421

Rather than handling on a case by case basis, with Javascript you can encode all data you pass via query string with encodeURIComponent

<script>
var data = ")(@&^$@*&^#!(!*++="; 
var encodedData = encodeURIComponent(data); 
alert(encodedData);
</script>

Upvotes: 4

polygenelubricants
polygenelubricants

Reputation: 383756

In ASCII, the hex code for + is 2B, so you should be able to just use %2B instead of +.

http://www.google.com/search?q=c%2B%2B+java

Upvotes: 0

Jakob
Jakob

Reputation: 24360

The space character is usually passed as %20. The same way, the plus sign can be passed as %2B

Upvotes: 1

Marcelo Cantos
Marcelo Cantos

Reputation: 185862

Use %2b to pass the + character.

Upvotes: 3

Related Questions