YAML files with Chinese

From my point of view, one of the advantages of YAML files is that
they’re easy to read and edit using normal text editors,
and don’t have all the excess cruft of XML files; yet working with
Chinese vocabulary lists has revealed some odd behavior.

Here’s my program and it’s output:

Is there some way to get the output I would like to see. The output of
yaml is not readable by humans, and I can’t verify it much
less change it.

Thanks in advance for any pointers.

Bryan

#!/usr/bin/env ruby

coding: utf-8

puts RUBY_VERSION
require ‘yaml’

vocab = {
“我” => “wǒ”,
“你” => “nǐ”
}

File.open(“VOCAB”, “w”) do |file|
YAML.dump(vocab, file)
file.puts “-------------------------”
file.puts “# This is what I would prefer to see”
file.puts “—”
vocab.each do |k,v|
file.puts “#{k}: #{v}”
end
end
puts cat VOCAB
END

What follows it the output from the above program

1.9.2

“\xE6\x88\x91”: “w\xC7\x92”
“\xE4\xBD\xA0”: “n\xC7\x90”

Am 19.06.2013 13:15, schrieb Bryan L.:

Bryan
}
puts cat VOCAB
你: nǐ
You posted the exact same question some time ago (May 27)!

Search for “hard-to-read yaml files” and “ruby-talk”.

As I already explained, you should use 2.0.0 or 1.9.3 if possible.
See my previous answer for further options.