Last active
February 16, 2017 15:25
-
-
Save JervenBolleman/63d8757cddee1e1d4594b9b42c127c71 to your computer and use it in GitHub Desktop.
Fix illegal encoded high/low surrogate pairs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
StringBuilder f = new StringBuilder(w.length()); | |
for (int i = 0; i < w.length(); i++) | |
{ | |
char c = w.charAt(i); | |
if (c >= 0xD800 && c <= 0xD8FF) | |
{ | |
int h = ((c - 0xD800) * 0x400); | |
int l = ((w.charAt(++i) - 0xDC00) + 0x10000); | |
f.append((char) (h + l)); | |
} | |
else | |
{ | |
f.append(c); | |
} | |
} | |
return f.toString(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment