String unescapeHTML(String s, int f){ String [][] escape = {{ "<" , "<" } , { ">" , ">" } , { "&" , "&" } , { """ , "\"" } , { "à" , "à" } , { "À" , "À" } , { "â" , "â" } , { "ä" , "ä" } , { "Ä" , "Ä" } , { "Â" , "Â" } , { "å" , "å" } , { "Å" , "Å" } , { "æ" , "æ" } , { "Æ" , "Æ" } , { "ç" , "ç" } , { "Ç" , "Ç" } , { "é" , "é" } , { "É" , "É" } , { "è" , "è" } , { "È" , "È" } , { "ê" , "ê" } , { "Ê" , "Ê" } , { "ë" , "ë" } , { "Ë" , "Ë" } , { "ï" , "ï" } , { "Ï" , "Ï" } , { "ô" , "ô" } , { "Ô" , "Ô" } , { "ö" , "ö" } , { "Ö" , "Ö" } , { "ø" , "ø" } , { "Ø" , "Ø" } , { "ß" , "ß" } , { "ù" , "ù" } , { "Ù" , "Ù" } , { "û" , "û" } , { "Û" , "Û" } , { "ü" , "ü" } , { "Ü" , "Ü" } , { " " , " " } , { "®" , "\u00a9" } , { "©" , "\u00ae" } , { "€" , "\u20a0" } , { "'", str(char(39))} }; int i, j, k, l ; i = s.indexOf("&", f); if (i > -1) { j = s.indexOf(";" ,i); // -------- // we don't start from the beginning // the next time, to handle the case of // the & // thanks to Pieter Hertogh for the bug fix! f = i + 1; // -------- if (j > i) { // ok this is not most optimized way to // do it, a StringBuffer would be better, // this is left as an exercise to the reader! String temp = s.substring(i , j + 1); // search in escape[][] if temp is there k = 0; while (k < escape.length) { if (escape[k][0].equals(temp)) break; else k++; } if (k < escape.length) { s = s.substring(0 , i) + escape[k][1] + s.substring(j + 1); return unescapeHTML(s, f); // recursive call } } } return s; }