1

I have tried with :-

1) URLEncoder. ---it gave me something like this "my+string+has+space".

2)Charset. -- it was not working. with "UTF-8" and "ISO-8859-1"

  • Why not just `String.replace`? – SantiBailors Apr 05 '17 at 05:36
  • 1
    What's wrong with #1? That is a perfectly valid URL encoding. Sure, `%20` is an *alternate* way to do it, but that doesn't make `+` any less valid. – Andreas Apr 05 '17 at 05:39
  • @SantiBailors right now I am using String.replace but is it valid?. – Vishwanath Kulkarni Apr 11 '17 at 10:38
  • @Andreas Our UAA(user authentication and Authorization) was not accepting "+" as properly encoded value. – Vishwanath Kulkarni Apr 11 '17 at 10:39
  • I don't see why not, but I don't know what's your concern about `String.replace` being "valid" or not. Can you specify ? The only possibility I can think of is if in your case you need not to replace inside some delimiters. BTW, [this question](http://stackoverflow.com/q/2678551/2814308) and the one linked from its only comment might give you useful info on the subject. – SantiBailors Apr 11 '17 at 14:47
  • 1
    If your string is to be used as a URL and your concern is about the encoding of the other characters that also need encoding, you could consider using `URLEncoder` and then replacing all the `+` with `%20`. – SantiBailors Apr 11 '17 at 16:06

0 Answers0