Exlll / ConfigLib

A Minecraft library for saving, loading, updating, and commenting YAML configuration files
MIT License
135 stars 17 forks source link

Charset string problem #24

Closed alexdev03 closed 1 year ago

alexdev03 commented 1 year ago

I put this string (&7➥ &7Complete the previus task) inside a List in a record and when I save in the yaml file I get (&7➥ &7Complete the previus task) I tried with the default one and also with bukkit.

image image

Exlll commented 1 year ago

Hey, @alexdev03!

I pasted that string into an example configuration and saved it; the output looks correct to me:

Screenshot from 2023-09-25 01-14-19

What program did you use to open that file? Perhaps it doesn't properly handle UTF-8 or you saved the source file (i.e. the .java file) using a different encoding (perhaps windows-1252 in case you are on Windows)?

alexdev03 commented 1 year ago

The code is run on Linux, on a paper server. I opened it with visual studio code. Also in game I get the same same string as vs code.

Exlll commented 1 year ago

As I cannot reproduce this problem (as shown in my screennshots above), I assume that your .java files are saved with some encoding other than UTF-8. Please make sure that (a) your editor uses UTF-8 when saving your .java files, (b) you call javac (the Java compiler) with the -encoding option set to UTF-8, and (c) that you start your server/the JVM with -Dfile.encoding also set to UTF-8.

alexdev03 commented 1 year ago

Intellij has as default encoding type UTF-8, I checked and i'ts correct. I tried by adding -Dfile.encoding as starting flag but the issue persists. I also checked the editor and vs code uses UTF-8 to open that file. I tried by opening that java file with vs code and the strings are correct.

I uploaded the classes that I use to create that file. Thanks

QuestObjective.zip

Exlll commented 1 year ago

Hm, the contents of the file look fine for me and still don't cause any issues on my system. What happens if you recomile your plugin with the things I said and also regenerate the config file (i.e. delete the old one) with the options I listed on your server? What is the output of java.nio.charset.Charset.defaultCharset() on your server?

alexdev03 commented 1 year ago

I fixed that, I use gradle as library and build system. And the default encoding wasn't UTF-8. I added compileJava.options.encoding = 'UTF-8' Thanks for the support