1

Possible Duplicate:
How to do URL decoding in Java?

I have string "Fran%c3%a7ais". How can I convert it to correct "Français" ?

Community
  • 1
  • 1
Tim
  • 1,606
  • 2
  • 20
  • 32

2 Answers2

3

Try URLDecoder:

URLDecoder.decode(String s)

According to the Docs the function is deprecated, so you'll need to use this one:

public static String decode(String s, String enc) throws UnsupportedEncodingException

Example:

String decoded = URLDecoder.decode("Fran%c3%a7ais", "UTF-8");
sfjac
  • 7,119
  • 5
  • 45
  • 69
ihsoy ih
  • 1,008
  • 2
  • 10
  • 20
0

That looks like percent-encoded UTF-8. For each maximal sequence of (percentsign)+(hex digit)+(hex digit), first convert it to bytes by taking each pair of hex digits to encode a byte; then interpret the resulting byte sequence as the UTF-8 encoding as the actual text.

hmakholm left over Monica
  • 23,074
  • 3
  • 51
  • 73