Solved UTF8 IN YamlConfiguration

Discussion in 'Spigot Plugin Development' started by MineSideLP, Feb 11, 2020.

Thread Status:
Not open for further replies.
  1. How can I save my String in UTF-8?

    Code (Java):
    this.yamlConfiguration.set("Name", "&8» &aTeleporter");
    Output

    Code (Java):
    Name: "&8\xbb &aTeleporter"
     
  2. Why not just put UTF8 in your code
     
  3. Because I dont want this xD
     
  4. What
    ..why
     
  5. What is so difficult to understand? I want to insert the special characters directly in the code.
     
  6. You will have to load as UTF-8
    Code (Java):
    FileConfiguration cFile = YamlConfiguration.loadConfiguration(file);
    Reader defConfigStream;
    try {
        defConfigStream = new InputStreamReader(JavaPlugin.getResource("file.yml"), "UTF8");
        if (defConfigStream != null) {
            YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
            cFile.setDefaults(defConfig);
       }
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    Or something like that
     
  7. your \xbb symbol is unicode. /xbb is the utf_8 translation of your symbol. if you want the symbol to render in the file, you need to save as the unicode character set. utf_8 is already the default.
     
  8. Okay thank you!
     
Thread Status:
Not open for further replies.