mcpi icon indicating copy to clipboard operation
mcpi copied to clipboard

Suggestion for postToChat() function to send garbled messages in the game

Open limingzxc opened this issue 3 years ago • 3 comments

I noticed that the bottom layer of the postToChat() function is sent to the game in utf-8 encoding, but the chat message box in minecraft seems to use gbk encoding, which causes sending non-ascii characters to become in-game Garbled, I suggest adding a parameter to allow the postToChat() function to choose the encoding of the message to avoid problems.

limingzxc avatar Jun 16 '22 09:06 limingzxc

I am not sure about Java Edition, but Pi edition uses CP437.

Bigjango13 avatar Jun 17 '22 21:06 Bigjango13

I tested on minecraft Java Edition 1.11.2 server, using minecraftPythonAPI plugin

limingzxc avatar Jun 17 '22 22:06 limingzxc

I changed the encoding in the _misc_to_bytes function to gbk, so that I can use postToChat() to send Chinese without garbled characters

limingzxc avatar Jun 17 '22 23:06 limingzxc