Gibberish text when displaying Crop Tier
SihenZhang opened this issue · 2 comments
Describe the bug
I was playing ATM 6 - To the Sky
and I found the crop tier of the custom crops is displayed as gibberish text.
Expected behavior
After reading the source code, I found that the script is read via FileReader
that uses Java's platform default encoding.
My operating system is Windows 11 in Simplified Chinese, and its default encoding is
GBK
, while the encoding of the script file is UTF-8
. Therefore, it displays the gibberish text.Since Java 11
FileReader
has gained constructors that accept an encoding: new FileReader(file, charset)
and new FileReader(fileName, charset)
.In earlier versions of java, you need to use
new InputStreamReader(new FileInputStream(pathToFile), <encoding>)
.
Screenshots / Scripts / Logs
magical.json
{
"name": "§bMagical",
"value": 8,
"farmland": "mysticalagradditions:insanium_farmland",
"essence": "mysticalagradditions:insanium_block",
"fertilizable": false,
"secondarySeedDrop": false
}
Versions (please complete the following information):
- Minecraft: 1.16.5
- Forge: 36.1.66
- Cucumber: 4.1.10
- Mystical Agriculture: 4.2.1
- Mystical Customization: 2.1.5
You should be able to encode the file in UTF-8. I remember back in the day I had this issue with minecraft translation files and having to re-encode them using notepad++.
Did you really read what he said?
The language file is encoded in UTF-8, but you have not specified to use UTF-8 to read the file, which in the Chinese area defaults to using GBK encoding to decode.
Related code: