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 aString)
Remove "escaped" chars from a string.
if (aString == null)
    return null;
String normalString = replace(aString, EQUAL_SIGN_ENTITY, EQUAL_SIGN);
normalString = replace(normalString, LINE_FEED_ENTITY, LINE_FEED);
normalString = replace(normalString, CARRIAGE_RETURN_ENTITY, CARRIAGE_RETURN);
normalString = replace(normalString, LINE_TAB_ENTITY, LINE_TAB);
return normalString;
Stringunescape(String aValue)
Unescapes hex values in a URI query value.
if (aValue == null) {
    return aValue;
char[] chars = aValue.toCharArray();
StringBuffer buf = new StringBuffer(chars.length);
for (int i = 0; i < chars.length; i++) {
    if (chars[i] == '%') {
        ++i;
...
Stringunescape(String data)
unescape
StringBuilder buffer = new StringBuilder(data.length());
for (int i = 0; i < data.length(); i++) {
    if ((int) data.charAt(i) > 256) {
        buffer.append("\\u").append(Integer.toHexString((int) data.charAt(i)));
    } else {
        if (data.charAt(i) == '\n') {
            buffer.append("\\n");
        } else if (data.charAt(i) == '\t') {
...
Stringunescape(String elt)
unescape
if (elt.length() == 0 || (elt.indexOf('\\') < 0 && elt.indexOf('"') < 0)) {
    return elt.trim();
char[] elts = elt.toCharArray();
boolean escaped = false;
boolean quoted = false;
StringBuffer buf = new StringBuffer(elt.length());
int start = 0;
...
Stringunescape(String entry)
Unescapes a given entry.
String unescaped = entry.trim();
if (unescaped.startsWith("\"") && unescaped.endsWith("\"")) {
    unescaped = unescaped.substring(1, unescaped.length() - 1);
    unescaped = unescaped.replace("\"\"", "\"");
return unescaped.trim();
Stringunescape(String escaped)
unescape
boolean escaping = false;
StringBuilder newString = new StringBuilder();
for (char c : escaped.toCharArray()) {
    if (!escaping) {
        if (c == ESCAPE_CHAR) {
            escaping = true;
        } else {
            newString.append(c);
...
Stringunescape(String escaped)
Unescape all escape sequences in string (strip one level of backslashes).
char[] source = escaped.toCharArray();
char[] dest = new char[source.length];
int j = 0;
for (int i = 0; i < source.length; i++) {
    if ((source[i] != '\\') || (i > 0 && source[i - 1] == '\\')) {
        dest[j++] = source[i];
return new String(dest, 0, j);
Stringunescape(String escaped, char escape)
Opposite of #escape(String,char,char)
StringBuilder sb = new StringBuilder(escaped.length());
for (int i = 0, n = escaped.length(); i < n; i++) {
    char c = escaped.charAt(i);
    if (c == escape) {
        i++;
        c = escaped.charAt(i);
    sb.append(c);
...
Stringunescape(String escapedMessage)
Returns a string with all escaped occurrence of StringUtils.SEPARATOR unescaped
return unescape(escapedMessage, SEPARATOR);
Stringunescape(String input)
Method description
return translateAll(input, encoded, decoded);