in yoko-util/src/main/java/org/apache/yoko/util/cmsf/RepIds.java [167:230]
private static String removeUnicodeEscapes(String in) {
// if no escape sequences are in the string, this is easy
int escape = in.indexOf("\\U");
if (escape < 0) {
return in;
}
StringBuilder out = new StringBuilder(in.length());
int start = 0;
while (escape >= 0) {
out.append(in.substring(start, escape));
// step over the escape sequence
escape += 2;
int value = 0;
for (int i=0; i<4; i++) {
char ch = in.charAt(escape++);
switch (ch) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
value = (value << 4) + ch - '0';
break;
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
value = (value << 4) + 10 + ch - 'a';
break;
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
value = (value << 4) + 10 + ch - 'A';
break;
default:
// not sure what to do here. Just treat it as a 0 nibble
value = (value << 4);
}
}
// now append this as a char value
out.append((char)value);
// now step and find the next one
start = escape;
escape = in.indexOf("\\U", escape);
}
// don't forget the trailing segment
if (start < in.length()) {
out.append(in.substring(start));
}
return out.toString();
}