Anchor should allow non ascii charactors while dumping

Issue #480 resolved
Takafumi Ohtake created an issue

Summary

On the below issue, anchor can contain non ascii characters like Japanese.

https://bitbucket.org/asomov/snakeyaml/issues/468/anchor-should-allow-non-ascii-charactors

But while dumping, if anchor contains non ascii characters, snakeyaml thorws EmmiterException from org.yaml.snakeyaml.emitter.Emitter#prepareAnchor.

It should be allowed to contains non ascii characters while dumping.

Environment

  • java

    • 1.8
  • snakeyaml

    • 1.26

Expected

  • Yaml specification allows non ascii characters. Snakeyaml should do so.

How to produce

  public void dump_non_ascii() {

    DumperOptions options = new DumperOptions();
    options.setAnchorGenerator(new AnchorGenerator() {
      int id = 0;

      @Override
      public String nextAnchor(Node node) {
        return "タスク" + id++;
      }
    });

    Yaml yaml = new Yaml(options);

    List<String> list = new ArrayList<>();
    list.add("abc");

    List<List<String>> toExport = new ArrayList<>();
    toExport.add(list);
    toExport.add(list);

    yaml.dump(toExport);
  }

Comments (4)

  1. Takafumi Ohtake reporter

    Thank your for your very fast fixing and perfect work.

    I’m looking for the next release.

  2. Log in to comment