haythem souissi
haythem souissi

Reputation: 3273

what is the equivalent of "-" in an url?

How to change - in url. I have got the same problem with space so i changed it with %20 and it worked:

name = name.replaceAll(" ","%20");

What is the equivalent of "-" in an url?

I tried %2C and it doesn't word: %2C -> ","

Upvotes: 0

Views: 250

Answers (3)

Christian Mann
Christian Mann

Reputation: 8125

It's the ascii code (translator). - translates to %2d. You were close :)

Upvotes: 0

marlboro
marlboro

Reputation: 264

As far as I know the dash char is considered a safe char in the URL. If you have problems, then the problems might have nothing to do with the dash. Try, though, to replace it with %2D.

Upvotes: 0

jsimpson
jsimpson

Reputation: 391

Use URLEncoder.encode(String s) to encode all your strings that you are gonna use for urls.

Upvotes: 2

Related Questions