I have an environment where strings are percent encoded by Actionscript escape() function and then passed to Java for decoding.
I have for example a test string "m é".
It is passed to Actionscript escape() that outputs "m%20%E9"
When I try to decode it with Java:
URLDecoder.decode("m%20%E9", "UTF-8")
The result is:
"m ?"
%E9 seems the unicode point for "é" character, but it is not quite understood by Java decode.
Is there a way to decode in Java the strings encoded by Actionscript escape()?
What escape format do these function use since they seem to be different?
Thanks in advance for any help,
Paolo
m%20%E9 is not UTF-8. That's easy to see because any character outside of the ASCII range (i.e. 0-127) would need at least 2 bytes in UTF-8. Since %20 is space, that leaves only %E9 for é.
And é is in fact U+00E9. The encoding maps 1:1 to Unicode in the lower 255 characters is ISO-8859-1.
So the correct way to decode this would be this:
URLDecoder.decode("m%20%E9", "ISO-8859-1")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With