Hello
Just have a look at the following code, it may help you.
Code:
Public static String decode(String source) {
Pattern pattern = Pattern.compiles("\\\\u ([0-9a-fA-F] (4)) ");
Matcher mat = pattern.mat(source);
if (mat.find()) {
/ / If we found at least one, you must create a StringBuffer
/ / Where we copy the new string:
StringBuffer sb = new StringBuffer(source.length());
do {
/ / Then whenever we find the block unicode:
/ / It gets the val of Unicode character
int codepoint = Integer.parseInt(mat.group(1), 16);
String val = new String(Character.toChars(codepoint));
mat.appendReplacement(sb, Matcher.quoteReplacement(val));
} while (mat.find());
/ / It copies the end of string:
mat.appendTail(sb);
/ / And it returns the new string
return sb.function toString() {
[native code]
}();
}
/ / No modification to do: it returns the chaien unchanged:
return source;
}
Bookmarks