Jaume Jaume - 1 year ago 120
Java Question

android UTF8 encoding from received string

I am receiving a string that is not properly encoded like "mystring%201, where must be "mystring 1". How could I replace all characters that could be interpreted as UTF8? I read a lot of posts but not a full solution. Please note that string is already encoded wrong and I am not asking about how to encode char sequence. I asked same issue for iOS few days ago and was solved using stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding. Thank you.

ios UTF8 encoding from nsstring

Answer Source

You should be able to use the URLDecoder.decode() function, like this:

String s = URLDecoder.decode(myString, "UTF-8");

More info here: URLEncoder encode / URLDecoder decode in java (Android)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download