-2

I have this URL https://plus.google.com/+pitneybowes, where + sign in url. I have used this url in my code anchor tage

but when i run my code and view it in browser it get replaced by this https://plus.google.com/%20pitneybowes

I want + sign in URL. it is necessary. How to solve this issue?

php_coder
  • 109
  • 1
  • 2
  • 12
  • Can you provide us your current code – Jaquarh Jan 24 '17 at 06:51
  • Can we see the code? – Kaylined Jan 24 '17 at 06:52
  • I called url using window.location.href="http://plus.google.com/+pitneybowes" the + sign is get replaced by %20 – php_coder Jan 24 '17 at 06:54
  • You could probably use `plus.google.com/%2Bpitneybowes` instead of adding the literal `+` as that's just an invitation to break things. – apokryfos Jan 24 '17 at 06:55
  • @apokryfos but without + it displays page not found error 404 – php_coder Jan 24 '17 at 06:59
  • 1
    Possible duplicate of [Why should I use urlencode?](http://stackoverflow.com/questions/4667942/why-should-i-use-urlencode) – yivi Jan 24 '17 at 07:06
  • @sujatak i've used the URL I supplied in my previous comment and it works for me which means the problem is in the code you're using to process it which you have yet to provide even though there were 2 comments that are asking for it. – apokryfos Jan 24 '17 at 07:08

2 Answers2

1

According to the URL specification, %20 and + are equivalent representations of an escaped space (ASCII 32). Whether a browser presents a %20 or + is implementation-dependent.

Your site should be designed to handle both. Or really, it should not be working with the raw URL, but the unescaped and parsed URL-- which in either case would contain a space.

If you really are coding your web site to require that spaces be represented as a + specifically, and this is somehow mission critical, you are setting yourself up for compatibility issues.

If you actually need a + in the URL (unescaped), the hex code for that is %2B.

Thus

Print(UrlEncode("This is a test"));    =  "This+is+a+test"
                                       or "This%20is%20a%20test"

Print(UrlDecode("This%20is+a%20test")) =  "This is a test"

Print(UrlEncode("What is 2+2?")        =  "What+is+2%2B2%3F"
John Wu
  • 50,556
  • 8
  • 44
  • 80
-1

You can use urlencode to encode your url. The decoding will happen automatically, and can get the value from $_GET.

Jyoti mishra
  • 597
  • 4
  • 16