Giter Club home page Giter Club logo

Comments (4)

Daschi1 avatar Daschi1 commented on June 14, 2024 2

It is working now. Everything is getting wrote and outputted properly now.
Thank you so much!

from simple-yaml.

Carleslc avatar Carleslc commented on June 14, 2024

I cannot reproduce it. Check that the encoding of your config.yml is UTF-8 in your text editor.

Also check the encoding of the YamlFile:

YamlFile yamlFile = new YamlFile("test-encoding.yml");

System.out.println("Default Charset: " + Charset.defaultCharset());
System.out.println("Allow Unicode: " + FileConfiguration.SYSTEM_UTF);

yamlFile.createNewFile(false);
yamlFile.load();

yamlFile.set("ö", "ö");
yamlFile.set("umlauts", "öüäß");
yamlFile.set("hiragana", "ひらがな");
yamlFile.set("kanji", "漢字");
yamlFile.set("emoji", "\uD83D\uDE01");

yamlFile.getValues(true).forEach((key, value) -> System.out.println(key + ": " + value));

yamlFile.save();

This is my output:

Default Charset: UTF-8
Allow Unicode: true
ö: ö
umlauts: öüäß
hiragana: ひらがな
kanji: 漢字
emoji: 😁

from simple-yaml.

Daschi1 avatar Daschi1 commented on June 14, 2024

The encoding of the config is displayed as UTF-8.
I have run your code and this is my output:

Default Charset: windows-1252
Allow Unicode: false
�: �
umlauts: ����
hiragana: ????
kanji: ??
emoji: ?

Although the config is encoded in UTF-8, it contains the following:

"\xf6": "\xf6"
umlauts: "\xf6\xfc\xe4\xdf"
hiragana: "\u3072\u3089\u304c\u306a"
kanji: "\u6f22\u5b57"
emoji: "\U0001f601"

Is this maybe a problem from the OS? (I am using Windows 10, what is yours?)

from simple-yaml.

Carleslc avatar Carleslc commented on June 14, 2024

I'm using MacOS. Your system or Java VM default charset does not accept Unicode characters and this API uses the default charset encoding to load/save files.

Some methods and fields were deprecated because of this, like the FileConfiguration.SYSTEM_UTF in my code above. I've updated the API to use UTF-8 by default, with an option to change the charset. I've also removed deprecated code related to encoding issues (as per Bukkit newest FileConfiguration).

Update to v1.6.1 or a newer version and run the code at YamlEncodingTest to ensure it is working on your system.

If desired, you can change the encoding to use the default with:

yamlFile.options().charset(Charset.defaultCharset());

from simple-yaml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.