Java Utililty Methods Unicode Unescape

List of utility methods to do Unicode Unescape

Description

The list of methods to do Unicode Unescape are organized into topic(s).

Method

StringunescapeHTMLUnicodeEntity(final String text)
unescape HTML Unicode Entity
final StringBuilder resultBuilder = new StringBuilder(text.length());
final StringBuilder entity = new StringBuilder();
boolean readingEntity = false;
char myChar;
for (int i = 0; i < text.length(); ++i) {
    myChar = text.charAt(i);
    if (readingEntity) {
        if (myChar == ';') {
...
StringunescapeUnicode(String encoded)
unescape Unicode
int length = encoded.length();
final StringBuilder sb = new StringBuilder(length);
for (int i = 0; i < length; i++) {
    final char currChar = encoded.charAt(i);
    if ('&' == currChar) {
        final StringBuilder codeBuilder = new StringBuilder(6);
        if ('u' != encoded.charAt(++i)) {
            throw new IllegalArgumentException("& not followed by u at position " + i + " in " + encoded);
...
StringunescapeUnicode(String s)
Unescape %XX and %uXXXX notation produced by the JavaScript's escape function
if (s == null || s.indexOf('%') == -1)
    return s;
StringBuilder unicode = new StringBuilder(1024);
StringBuilder sb = new StringBuilder(4);
boolean hadPct = false;
boolean inUnicode = false;
boolean inByte = false;
for (int i = 0; i < s.length(); i++) {
...
StringunescapeUnicode(String s)
Unescapes unicode sequences and stores them as unicode characters instead.
StringBuilder result;
int index;
String unicode;
char[] chars;
if (!s.contains("\\u"))
    return s;
result = new StringBuilder();
while ((index = s.indexOf("\\u")) > -1) {
...
StringunescapeUnicodeChars(String string)
Unescapes \\uXXXX encoded chars.
int pos = string.indexOf("\\u");
if (pos < 0) {
    return string;
StringBuilder newString = new StringBuilder();
int charValue, oldPos = 0;
while ((pos >= 0) && (pos + 5 < string.length())) {
    newString.append(string.substring(oldPos, pos));
...