pdinklag / MinecraftStats

A Minecraft player statistics browser for the web - supports 1.13 and later!
https://discord.gg/brH5PGG8By
Other
226 stars 53 forks source link

Server motd with non-ascii characters can't be processed properly #234

Closed KoishiMoe closed 6 months ago

KoishiMoe commented 8 months ago

A simple example:

motd=测试

It should be converted to \u6d4b\u8bd5, but in fact it's converted to \u00e6\u00b5\u008b\u00e8\u00af\u0095 (测è¯)

The old python version can do this properly. Seems that java.util.Properties will try ASCII by default. I tried to fix it in this commit, but I'm not sure if there're better ways to do it.

pdinklag commented 7 months ago

Thanks.

Yeah, it's really a nuisance that Python could handle things just fine, but Java - for which the properties format was basically invented - can't. If your solution works, it may be just an encoding issue after all. Question is what does Python do in order to handle things right without any hints as to the encoding?

KoishiMoe commented 7 months ago

Thanks for your tip. I checked the source of the official server and found that it would try to open the file in UTF-8 first, and if it failed, it would fall back to ISO_8859_1. And it only uses UTF-8 when saving it. I'll send a pr soon.