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 source)
unescape
if (source == null) {
    return "";
char c;
StringBuilder buffer = new StringBuilder();
for (int i = 0, length = source.length(); i < length; i++) {
    c = source.charAt(i);
    if (c == '\\' && (i + 1 < length)) {
...
Stringunescape(String src)
Un-escapes the passed string, replacing the standard slash escapes with their corresponding unicode character value.
if (src == null)
    return null;
StringBuilder sb = new StringBuilder(src);
for (int ii = 0; ii < sb.length(); ii++) {
    if (sb.charAt(ii) == '\\') {
        sb.deleteCharAt(ii);
        if ((sb.charAt(ii) == 'u') || (sb.charAt(ii) == 'U')) {
            int c = (hex2dec(sb.charAt(ii + 1)) << 12) + (hex2dec(sb.charAt(ii + 2)) << 8)
...
Stringunescape(String src)
undoes the operations of escape
if (src == null)
    return null;
final StringBuffer result = new StringBuffer();
for (int i = 0; i < src.length(); i++) {
    final char curChar = src.charAt(i);
    if (curChar != '\\') {
        result.append(curChar);
        continue;
...
Stringunescape(String src)
unescape
StringBuilder sb = new StringBuilder();
sb.ensureCapacity(src.length());
int lastPos = 0;
int pos = 0;
while (lastPos < src.length()) {
    pos = src.indexOf("%", lastPos);
    if (pos == lastPos) {
        if (src.charAt(pos + 1) == 'u') {
...
Stringunescape(String src)
unescape
if (src == null)
    return null;
StringBuffer tmp = new StringBuffer();
tmp.ensureCapacity(src.length());
int lastPos = 0, pos = 0;
char ch;
while (lastPos < src.length()) {
    pos = src.indexOf("%", lastPos);
...
Stringunescape(String st)
Unescapes a string that contains standard Java escape sequences.
StringBuilder sb = new StringBuilder(st.length());
for (int i = 0; i < st.length(); i++) {
    char ch = st.charAt(i);
    if (ch == '\\') {
        char nextChar = (i == st.length() - 1) ? '\\' : st.charAt(i + 1);
        if (nextChar >= '0' && nextChar <= '7') {
            String code = "" + nextChar;
            i++;
...
Stringunescape(String str)
unescape
if (str == null || str.length() == 0)
    return "";
final StringBuilder result = new StringBuilder();
int len = str.length();
for (int i = 0; i < len; i++) {
    char character = str.charAt(i);
    switch (character) {
    case '_':
...
Stringunescape(String str)
unescape
int idxS = str.indexOf('&');
if (idxS < 0) {
    return str;
StringBuilder sb = new StringBuilder(str.length());
int idxE, idx, size;
char c;
int prev = 0;
...
Stringunescape(String str)
unescape
if (str == null) {
    return null;
int len = str.length();
if (len <= 1) {
    return str;
StringBuilder ret = new StringBuilder(len - 2);
...
Stringunescape(String str)
unescape
if (str == null)
    return null;
if (str.length() == 0)
    return str;
for (int i = ENTITIES.length - 1; i >= 0; i--) {
    str = str.replace(ENTITIES[i][1], ENTITIES[i][0]);
return str;
...