Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>we started with Vartec's solution but found out additional issues. This solution works for UTF-16, but it can be changed to return UTF-8. The replace all is left for clarity reasons and you can read more at <a href="http://www.cogniteam.com/wiki/index.php?title=DecodeEncodeJavaScript" rel="nofollow">http://www.cogniteam.com/wiki/index.php?title=DecodeEncodeJavaScript</a></p> <pre><code>static public String unescape(String escaped) throws UnsupportedEncodingException { // This code is needed so that the UTF-16 won't be malformed String str = escaped.replaceAll("%0", "%u000"); str = str.replaceAll("%1", "%u001"); str = str.replaceAll("%2", "%u002"); str = str.replaceAll("%3", "%u003"); str = str.replaceAll("%4", "%u004"); str = str.replaceAll("%5", "%u005"); str = str.replaceAll("%6", "%u006"); str = str.replaceAll("%7", "%u007"); str = str.replaceAll("%8", "%u008"); str = str.replaceAll("%9", "%u009"); str = str.replaceAll("%A", "%u00A"); str = str.replaceAll("%B", "%u00B"); str = str.replaceAll("%C", "%u00C"); str = str.replaceAll("%D", "%u00D"); str = str.replaceAll("%E", "%u00E"); str = str.replaceAll("%F", "%u00F"); // Here we split the 4 byte to 2 byte, so that decode won't fail String [] arr = str.split("%u"); Vector&lt;String&gt; vec = new Vector&lt;String&gt;(); if(!arr[0].isEmpty()) { vec.add(arr[0]); } for (int i = 1 ; i &lt; arr.length ; i++) { if(!arr[i].isEmpty()) { vec.add("%"+arr[i].substring(0, 2)); vec.add("%"+arr[i].substring(2)); } } str = ""; for (String string : vec) { str += string; } // Here we return the decoded string return URLDecoder.decode(str,"UTF-16"); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload