android UTF8 encoding from received string

android, java

Solution

You can use the URLDecoder.decode() function, like this:

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

Problem

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

Original source

Related problems