Mojira Archive
MCPE-121996

Command Block UTF-8 slicing error

Steps to Reproduce:

1) Paste this command into a command block

/kill @e[name=§9§lDiscord Kit]

2) Place a button on the command block and press it

3) Right click on the command block and view the previous output field

 

Observed Results:{}

Previous output field will look like this

Syntax error: Unexpected "Kit": at 

 

Expected Results:

Previous output field should look like this with colour formatting

Syntax error: Unexpected "Kit": at "Discord >>Kit<<]"

 

The string after `at` is just the symptom of a larger issue. The reason it can't be displayed is because the code to crop the string splits a character in half making an invalid UTF-8 string that cannot be displayed. This invalid string also gets saved to the game files.

 

Extended Details:

The `§` character is encoded as `\xC2\xA7` as is correctly saved in the `Command` field but when the `LastOutputParams` field is created instead of treating these two bytes as one character like they are they are treated as two individual bytes. This leads to the result of `\xA7lDiscord ` which the game tries to interpret but it is invalid so it is not able to. If sliced correctly it would look like `\xC2\xA7lDiscord ` and would be able to be displayed.

This result is also saved to disk in the `LastOutputParams` field.

 

Here is the binary NBT of the `LastOutputParams` if it helps debug the issue.

`09 10 00 4C 61 73 74 4F 75 74 70 75 74 50 61 72 61 6D 73 08 03 00 00 00 0A 00 A7 6C 44 69 73 63 6F 72 64 20 03 00 4B 69 74 01 00 5D`

Unresolved

gentlegiantJGC

2021-03-20, 01:29 PM

2022-01-25, 04:03 PM

2

1

Plausible

704635

1.18.0.27 Beta, 1.16.210, 1.16.221 Hotfix

-