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,565
  • 2
  • 17
  • 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
  • 6,814
  • 5
  • 44
  • 65
ihsoy ih
  • 967
  • 2
  • 9
  • 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
  • 22,498
  • 2
  • 49
  • 73