0

I am sending a parameter string value, a french character "ç", to my web service in JAVA thorough GET method. In java, it is shown in UTF-8 encoded form as %C3%A7.

How can I convert it back to the same french character during the execution itself?

Frédéric Hamidi
  • 258,201
  • 41
  • 486
  • 479
  • 1
    By using UTF-8 as the expected encoding on the page. You need to be more explicit about the technology you use for the web service if you want a specific answer. – RealSkeptic Oct 14 '15 at 10:42
  • I'm using REST for the web service. Let's forget the web service for once, I already have the string in UTF-8 encoded form (think of it as hard coded) in my code and now I want to convert it into normal text and I'm not sure how to do that. – Ankan Priya Oct 14 '15 at 10:58
  • " In java, it is shown in UTF-8 encoded form as %C3%A7." - and how are you doing that exactly? How do you obtain the data, and how do you print it? – Gimby Oct 14 '15 at 11:27
  • I'm obtaining the data as part of Input JSON. I'm printing it in JAVA using System.out.println(); – Ankan Priya Oct 14 '15 at 11:54
  • Possible duplicate of [How to do URL decoding in Java?](http://stackoverflow.com/questions/6138127/how-to-do-url-decoding-in-java) – Joe Oct 14 '15 at 11:58

1 Answers1

1

Tha answer you nned is the one liked by @Joe; you need to "convert" the query string:

String result = java.net.URLDecoder.decode(url, "UTF-8");

It's not a matter of UTF-8 econding, rather a url enconding one.

A side note: in the comments you stated that you are passing the data via GET, if the semantic of the web service is to modify the data I suggest to use the POST method.

Giovanni
  • 3,951
  • 2
  • 24
  • 30