List of utility methods to do XML String Unescape
String | xmlUnescape(String xml) Notice that this function only escape entity reference and not character reference. return xml.replaceAll("<", "<").replaceAll(">", ">") .replaceAll(""", "\"").replaceAll("'", "'") .replaceAll("&", "&"); |
String | unescape(String input) Useful to replace the escaped characters their unescaped counterparts Ex: & -> & return input.replace("&", "&").replace("<", "<") .replace(">", ">").replace(""", "\"") .replace("'", "\'"); |
String | unescape(String source) unescape for (char unescape_symbol : unescape_symbols) { source = source.replaceAll( String.format("&#%s;", (int) unescape_symbol), unescape_symbol + ""); return source; |
String | unescapeXML(final String xml) unescape XML Pattern xmlEntityRegex = Pattern.compile("&(#?)([^;]+);"); StringBuffer unescapedOutput = new StringBuffer(xml.length()); Matcher m = xmlEntityRegex.matcher(xml); Map<String, String> builtinEntities = null; String entity; String hashmark; String ent; int code; ... |
String | urlEscape(String s) Do a simple RFC2396 encoding s = s.replace("%", "%25"); s = s.replace(" ", "%20"); s = s.replace("!", "%21"); s = s.replace("\"", "%22"); s = s.replace("#", "%23"); s = s.replace("$", "%24"); s = s.replace("&", "%26"); s = s.replace("'", "%27"); ... |
String | replaceEscape(String result) replace Escape if (result == null) { return ""; result = result.replace("\\n", "\n"); result = result.replace("'", "'"); result = result.replace(""", "\""); result = result.replace("apos;", "'"); result = result.replace("quot;", "\""); ... |
String | replaceEscapeSequence(String input) replace Escape Sequence String output = null; if (input != null) { output = input.replaceAll("<", "<"); output = output.replaceAll(">", ">"); output = output.replaceAll("&", "&"); output = output.replaceAll("'", "??"); output = output.replaceAll(""", "\""); return output; |
String | unescape(String text) Unescaping some chars and symbols return text.replace("&", "&").replace(""", "\"") .replace("<br>", "\n").replace(">", ">") .replace("<", "<").replace("'", "'") .replace("<br/>", "\n").replace("–", "-") .replace("!", "!").trim(); |