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 str, char escapeChar, char[] targetChars, char[] escapedChars)
unescape
return unescape(str, escapeChar, targetChars, escapedChars, false);
Stringunescape(String string)
unescape
StringBuffer result = new StringBuffer();
if (string.length() > 0) {
    if (string.charAt(0) == '"' && string.charAt(string.length() - 1) == '"') {
        result.append(string.substring(1, string.length() - 1));
    } else {
        boolean escape = false;
        char currentchar;
        for (int i = 0; i < string.length(); i++) {
...
Stringunescape(String string)
This method unescapes special characters in the given string.
StringBuilder sb = new StringBuilder();
boolean wasEscape = false;
boolean unicode = false;
int count = 0;
for (char c : string.toCharArray()) {
    if (unicode) {
        sb.append(c);
        if (++count == 4) {
...
Stringunescape(String string)
unescape
assert string != null;
StringBuilder buf = new StringBuilder();
int start = 0;
while (true) {
    int index = string.indexOf('\\', start);
    if (index < 0) {
        break;
    buf.append(string.substring(start, index));
    if (index != string.length() - 1) {
        buf.append(string.charAt(index + 1));
        start = index + 2;
    } else {
        buf.append(string.charAt(index));
        start = index + 1;
if (start < string.length()) {
    buf.append(string.substring(start));
return buf.toString();
Stringunescape(String string)
unescape
StringBuffer stringbuffer = new StringBuffer();
int i = 0;
for (int i_2_ = string.length(); i < i_2_; i++) {
    char c = string.charAt(i);
    if ('A' <= c && c <= 'Z')
        stringbuffer.append((char) c);
    else if ('a' <= c && c <= 'z')
        stringbuffer.append((char) c);
...
Stringunescape(String string)
Returns the specified string with Java escape sequences (that is '\n', '\u00E9', etc) replaced by the corresponding character.
return unescape(string, 0, string.length());
Stringunescape(String string, int escape)
unescape
StringBuilder buffer = new StringBuilder(string.length());
int i = string.indexOf(escape), b = 0;
while (i >= 0) {
    buffer.append(string.substring(b, i));
    if (i + 1 < string.length()) {
        buffer.append(string.charAt(i + 1));
    b = i + 2;
...
Stringunescape(String text)
unescape
for (int i = escapeMappings.length - 1; i >= 0; i--) {
    text = text.replace(escapeMappings[i][1], escapeMappings[i][0]);
return text;
Stringunescape(String text)
Unescapes the provided text with XML entities, see (http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entities_in_XML)
String s = text;
if (s != null && s.matches(".*&(.*);.*")) {
    s = s.replaceAll("&quot;", "\"");
    s = s.replaceAll("&amp;", "&");
    s = s.replaceAll("&apos;", "'");
    s = s.replaceAll("&lt;", "<");
    s = s.replaceAll("&gt;", ">");
return s;
Stringunescape(String text)
unescape
if (!text.contains("\\")) {
    return text;
int len = text.length();
StringBuilder sb = new StringBuilder(len);
for (int i = 0; i < len; i++) {
    char c = text.charAt(i);
    if (c == '\\') {
...