I am having an issue unescaping special characters in Java encoded with the Javascript escape() method.
Chrome console:
escape( "Gaëtan" )
"Ga%EBtan"
Java side:
(new org.apache.commons.codec.net.URLCodec()).decode("Ga%EBtan", "UTF-8")
Ga�tan
java.net.URLDecoder.decode( "Ga%EBtan", "UTF-8" )
Ga�tan
None of the methods in org.apache.commons.lang3.StringEscapeUtils can decode the string either.
The code that this is going for is married to the escape() method since it was written a very long time a go. I cannot change it without investing a serious amount of work so if I can avoid it, I want to.
The only thing that does work, but this is a performance hit:
( new javax.script.ScriptEngineManager() ).getEngineByName("JavaScript").eval( "unescape('Ga%EBtan')" )
Gaëtan
Any ideas? :)