src/main/java/org/jivesoftware/smack/util/StringUtils.java
public static String unescapeNode(String node) {
        if (node == null) {
            return null;
        }
        char[] nodeChars = node.toCharArray();
        StringBuilder buf = new StringBuilder(nodeChars.length);
        for (int i = 0, n = nodeChars.length; i < n; i++) {
            compare: {
                char c = node.charAt(i);
                if (c == '\\' && i + 2 < n) {
                    char c2 = nodeChars[i + 1];
                    char c3 = nodeChars[i + 2];
                    if (c2 == '2') {
                        switch (c3) {
                        case '0':
                            buf.append(' ');
                            i += 2;
                            break compare;
                        case '2':
                            buf.append('"');
                            i += 2;
                            break compare;
                        case '6':
                            buf.append('&');
                            i += 2;
                            break compare;
                        case '7':
                            buf.append('\'');
                            i += 2;
                            break compare;
                        case 'f':
                            buf.append('/');
                            i += 2;
                            break compare;
                        }
                    } else if (c2 == '3') {
                        switch (c3) {
                        case 'a':
                            buf.append(':');
                            i += 2;
                            break compare;
                        case 'c':
                            buf.append('<');
                            i += 2;
                            break compare;
                        case 'e':
                            buf.append('>');
                            i += 2;
                            break compare;
                        }
                    } else if (c2 == '4') {
                        if (c3 == '0') {
                            buf.append("@");
                            i += 2;
                            break compare;
                        }
                    } else if (c2 == '5') {
                        if (c3 == 'c') {
                            buf.append("\\");
                            i += 2;
                            break compare;
                        }
                    }
                }
                buf.append(c);
            }
        }
        return buf.toString();
    }
public static String unescapeNode(String node) {
        if (node == null) {
            return null;
        }
        char[] nodeChars = node.toCharArray();
        StringBuilder buf = new StringBuilder(nodeChars.length);
        for (int i = 0, n = nodeChars.length; i < n; i++) {
            compare: {
                char c = node.charAt(i);
                if (c == '\\' && i + 2 < n) {
                    char c2 = nodeChars[i + 1];
                    char c3 = nodeChars[i + 2];
                    if (c2 == '2') {
                        switch (c3) {
                        case '0':
                            buf.append(' ');
                            i += 2;
                            break compare;
                        case '2':
                            buf.append('"');
                            i += 2;
                            break compare;
                        case '6':
                            buf.append('&');
                            i += 2;
                            break compare;
                        case '7':
                            buf.append('\'');
                            i += 2;
                            break compare;
                        case 'f':
                            buf.append('/');
                            i += 2;
                            break compare;
                        }
                    } else if (c2 == '3') {
                        switch (c3) {
                        case 'a':
                            buf.append(':');
                            i += 2;
                            break compare;
                        case 'c':
                            buf.append('<');
                            i += 2;
                            break compare;
                        case 'e':
                            buf.append('>');
                            i += 2;
                            break compare;
                        }
                    } else if (c2 == '4') {
                        if (c3 == '0') {
                            buf.append("@");
                            i += 2;
                            break compare;
                        }
                    } else if (c2 == '5') {
                        if (c3 == 'c') {
                            buf.append("\\");
                            i += 2;
                            break compare;
                        }
                    }
                }
                buf.append(c);
            }
        }
        return buf.toString();
    }
public static String unescapeNode ( String node ) { if ( node == null ) { return null ; } char [ ] nodeChars = node . toCharArray ( ) ; StringBuilder buf = new StringBuilder ( nodeChars . length ) ; for ( int i = 0 , n = nodeChars . length ; i < n ; i ++ ) { compare : { char c = node . charAt ( i ) ; if ( c == ' ' && i + 2 < n ) { char c2 = nodeChars [ i + 1 ] ; char c3 = nodeChars [ i + 2 ] ; if ( c2 == ' ' ) { switch ( c3 ) { case ' ' : buf . append ( ' ' ) ; i += 2 ; break compare ; case ' ' : buf . append ( ' ' ) ; i += 2 ; break compare ; case ' ' : buf . append ( ' ' ) ; i += 2 ; break compare ; case ' ' : buf . append ( ' ' ) ; i += 2 ; break compare ; case ' ' : buf . append ( ' ' ) ; i += 2 ; break compare ; } } else if ( c2 == ' ' ) { switch ( c3 ) { case ' ' : buf . append ( ' ' ) ; i += 2 ; break compare ; case ' ' : buf . append ( ' ' ) ; i += 2 ; break compare ; case ' ' : buf . append ( ' ' ) ; i += 2 ; break compare ; } } else if ( c2 == ' ' ) { if ( c3 == ' ' ) { buf . append ( "@" ) ; i += 2 ; break compare ; } } else if ( c2 == ' ' ) { if ( c3 == ' ' ) { buf . append ( "\\" ) ; i += 2 ; break compare ; } } } buf . append ( c ) ; } } return buf . toString ( ) ; }
Un-escapes the node portion of a JID according to "JID Escaping"
(JEP-0106).
<p>
Escaping replaces characters prohibited by node-prep with escape
sequences, as follows:
<p>

<table border="1">
<tr>
<td><b>Unescaped Character</b></td>
<td><b>Encoded Sequence</b></td>
</tr>
<tr>
<td>&lt;space&gt;</td>
<td>\20</td>
</tr>
<tr>
<td>"</td>
<td>\22</td>
</tr>
<tr>
<td>&</td>
<td>\26</td>
</tr>
<tr>
<td>'</td>
<td>\27</td>
</tr>
<tr>
<td>/</td>
<td>\2f</td>
</tr>
<tr>
<td>:</td>
<td>\3a</td>
</tr>
<tr>
<td>&lt;</td>
<td>\3c</td>
</tr>
<tr>
<td>&gt;</td>
<td>\3e</td>
</tr>
<tr>
<td>@</td>
<td>\40</td>
</tr>
<tr>
<td>\</td>
<td>\5c</td>
</tr>
</table>
<p>

This process is useful when the node comes from an external source that
doesn't conform to nodeprep. For example, a username in LDAP may be
"Joe Smith". Because the &lt;space&gt; character isn't a valid part of a
node, the username should be escaped to "Joe\20Smith" before being made
into a JID (e.g. "joe\20smith@example.com" after case-folding, etc. has
been applied).
<p>

All node escaping and un-escaping must be performed manually at the
appropriate time; the JID class will not escape or un-escape
automatically.

@param node
the escaped version of the node.
@return the un-escaped version of the node.
Un - escapes the node portion of a JID according to JID Escaping ( JEP - 0106 ) . <p > Escaping replaces characters prohibited by node - prep with escape sequences as follows : <p >