Java Utililty Methods String Unescape

List of utility methods to do String Unescape

Description

The list of methods to do String Unescape are organized into topic(s).

Method

Stringunescape(String value)
Reverse the escaping of the control characters to get the original string.
if (value == null) {
    return value;
if (value.length() == 0) {
    return value;
return value.replace("&gt;", ">").replaceAll("&lt;", "<").replaceAll("&amp;", "&");
Stringunescape(String value)
If the string is enclosed in double or single quotes, the value inside the quotes is returned with all the escaped characters unescaped.
if (value == null)
    return value;
if (value.startsWith("\"")) {
    return value.substring(1, value.length() - 1).replaceAll("\\\"", "\"");
} else if (value.startsWith("'")) {
    return value.substring(1, value.length() - 1).replaceAll("\\'", "'");
return value;
...
Stringunescape(String value)
Unescape string
if (value == null || value.length() == 0) {
    return value;
StringBuffer buffer = new StringBuffer();
int pos = 0, max = value.length();
while (pos < max) {
    Character current = value.charAt(pos);
    if (current == '\\' && (pos + 1) < max) {
...
Stringunescape(String x)
This finds any '%xx' and converts to the equivilent char.
if (x.indexOf('%') < 0) {
    return x;
char[] b = new char[2];
StringBuilder sb = new StringBuilder(x);
for (int pos = 0; pos < sb.length(); pos++) {
    char c = sb.charAt(pos);
    if (c != '%') {
...
voidunescape(StringBuilder escapedText, int index)
Unescape html This method modify the StringBuilder in place.
int start, end, table_index;
start = escapedText.indexOf("&", index);
if (start > -1) {
    end = escapedText.indexOf(";", start);
    index = start + 1;
    if (end > start) {
        String temp = escapedText.substring(start, end + 1);
        table_index = 0;
...
StringunEscapeString(final String src)
Unescapes the given source string.
return unEscapeString(src, ESCAPE, COMMA);
StringunescapeString(String escapedString)
Replaces all the printf-style escape sequences in a string with the appropriate characters.
StringBuffer sb = new StringBuffer();
for (int i = 1; i < escapedString.length() - 1; ++i) {
    char c = escapedString.charAt(i);
    if (c == '\\') {
        ++i;
        sb.append(unescapeChar(escapedString.charAt(i)));
    } else {
        sb.append(c);
...
StringunescapeString(String iccProfileSrc)
unescape String
if (iccProfileSrc.startsWith("\"") || iccProfileSrc.startsWith("'")) {
    iccProfileSrc = iccProfileSrc.substring(1);
if (iccProfileSrc.endsWith("\"") || iccProfileSrc.endsWith("'")) {
    iccProfileSrc = iccProfileSrc.substring(0, iccProfileSrc.length() - 1);
return iccProfileSrc;
StringunescapeString(String in)
unescape String
if (in == null) {
    return null;
return in.replace("<br/>", "\n").replace("&nbsp;", " ").replace("&#039;", "\'").replace("&#034;", "\"")
        .replace("&lt;", "<").replace("&gt;", ">");
StringunescapeString(String inp)
Removes the first level of escapes from a string
StringBuffer sb = new StringBuffer();
int size = inp.length();
for (int i = 0; i < size; i++) {
    char ch = inp.charAt(i);
    if (ch == '\\') {
        i++;
        if (i >= size) {
            throw new IllegalArgumentException(
...