creative
creative copied to clipboard
Fix Custom Unicode characters
When using unicode characters in the extended charset (UTF-16BE), which is what Vanilla Minecraft supports. I attempt to add the char (due to the BE, two chars represent 1 char) "\uDBBC\uDC01", however unfortuantely it es escaped automatically to "\\uDBBC\\uDC01". Could we add an override for \u not to be overriden to \\u.
Could you provide some sample code or, preferably, open a pull request adding a test on that?
This issue is mostly caused by trying to use UTF-16 chars (which have a low surrogate and high surrogate), because of line 250 in ResourceWriter any (low and high surrogates) UTF-16 character that isn't an ASCII Value or U+2028 or U+2029 will simply be skipped.
In principable to reproduce you can try to give the character 0xFFFFF a custom mapping. (0xFFFFF is a perfectly fine UTF-16 Char that is split into 2 char surrogates).
My solution in my private fork was to simply add the following in the if block on line 250
...
else if (c >= '\u20B0') {
replacement = String.format("\\u%04x", (int) c);
} else {
continue
}
https://gist.github.com/tryashtar/6b2692e11ad46124e5129614fb7856a8
As discussed in the Discord Server here, Unicode characters should already work
I tested by myself too (Vanilla Minecraft 1.17.1, 1.18.2, 1.19.3):