Search code examples
javaandroidencodingcharacter-encodingencode

How to convert special characters, "Fran%c3%a7ais" -> "Français"?


Possible Duplicate:
How to do URL decoding in Java?

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


Solution

  • 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");