i have a String displayed on a WebView as “Siwy & Para Wino”
i fetch it from url , i got a string “Siwy%2B%2526%2BPara%2BWino”. // be corrected
now i’m trying to use URLDecoder to solve this problem :
String decoded_result = URLDecoder.decode(url); // the url is "Siwy+%26+Para+Wino"
then i print it out , i still saw “Siwy+%26+Para+Wino”
Could anyone tell me why?
From the documentation (of URLDecoder):
We can look at the specification to see what a
form-urlencodedMIME type is:Since the specification calls for a percent sign followed by two hexadecimal digits for the ASCII code, the first time you call the
decode(String s)method, it converts those into single characters, leaving the two additional characters26intact. The value%25translates to%so the result after the first decoding is%26. Running decode one more time simply translates%26back into&.You can also use the Uri class if you have UTF-8-encoded strings:
Then use: