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 quoted)
unescape
StringBuilder buf = new StringBuilder();
int i = quoted.length();
for (int n = 0; n < i; n++) {
    char c = quoted.charAt(n);
    if (c != '\\')
        buf.append(c);
    else if (n < i - 1 && quoted.charAt(n + 1) == '\\') {
        buf.append(c);
...
Stringunescape(String s)
unescape
if (s == null)
    return null;
if (s.equals(""))
    return null;
StringBuilder result = new StringBuilder(s.length());
for (int i = 0; i < s.length(); i++) {
    if (s.charAt(i) == '\\') {
        if (i + 1 == s.length())
...
Stringunescape(String s)
Decodes a string escaped by the Internet Explorer's Javascript escape() method to a Unicode String.
if (s == null || s.length() == 0) {
    return s;
StringBuffer sb = new StringBuffer(s.length());
for (int i = 0; i < s.length(); ++i) {
    char c = s.charAt(i);
    switch (c) {
    case '%':
...
StringunEscape(String s)
un Escape
String value = s;
value = value.replaceAll("&lt;", "<");
value = value.replaceAll("&gt;", ">");
value = value.replaceAll("&amp;", "&");
value = value.replaceAll("&quot;", "\"");
value = value.replaceAll("&apos;", "'");
return value;
Stringunescape(String s)
unescape
StringBuffer sbuf = new StringBuffer();
int i = 0;
int len = s.length();
while (i < len) {
    int ch = s.charAt(i);
    if (ch == '+') { 
        sbuf.append(' ');
    } else if ('A' <= ch && ch <= 'Z') { 
...
Stringunescape(String s)
unescape
if (s == null || s.length() == 0)
    return s;
StringBuilder sb = new StringBuilder();
char prev_ch = 0;
for (int i = 0, len = s.length(); i < len; i++) {
    char ch = s.charAt(i);
    switch (ch) {
    case '\\':
...
Stringunescape(String s)
Unescape \n, \r, \t, and \0xxx unicode escapes
int l = s.length();
StringBuffer dest = null;
int i = 0;
while (i < l - 1) {
    char c = s.charAt(i);
    if (c == '\\') {
        if (dest == null) {
            dest = new StringBuffer(l);
...
StringUnescape(String s)
Unescape
if (s.startsWith(QUOTE) && s.endsWith(QUOTE)) {
    s = s.substring(1, s.length() - 2);
    if (s.contains(ESCAPED_QUOTE))
        s = s.replace(ESCAPED_QUOTE, QUOTE);
return s;
Stringunescape(String s)
unescape
return unescape(s, null);
Stringunescape(String s)
Resolve escape sequences in a String.
if (s == null) {
    throw new IllegalArgumentException("The String to unescape may not be null.");
StringBuilder sb = new StringBuilder();
boolean escaped = false;
for (int i = 0; i < s.length(); i++) {
    char c = s.charAt(i);
    if (escaped) {
...