creative icon indicating copy to clipboard operation
creative copied to clipboard

Fix Custom Unicode characters

Open Articdive opened this issue 2 years ago • 3 comments

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.

Articdive avatar Jul 10 '22 10:07 Articdive

Could you provide some sample code or, preferably, open a pull request adding a test on that?

yusshu avatar Oct 09 '22 21:10 yusshu

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
}

Articdive avatar Oct 16 '22 06:10 Articdive

https://gist.github.com/tryashtar/6b2692e11ad46124e5129614fb7856a8

Septicuss avatar Oct 30 '22 09:10 Septicuss

As discussed in the Discord Server here, Unicode characters should already work

image

I tested by myself too (Vanilla Minecraft 1.17.1, 1.18.2, 1.19.3):

image image

yusshu avatar Jan 10 '23 15:01 yusshu