Skip to content

Instantly share code, notes, and snippets.

@tonini
Created January 22, 2010 07:50
Show Gist options
  • Save tonini/283578 to your computer and use it in GitHub Desktop.
Save tonini/283578 to your computer and use it in GitHub Desktop.
# encoding: utf-8
require "yaml"
require "yaml/encoding"
input_for_yaml = {
:phonetic_notation => "[ə’kɒmplɪʃ]",
:words => ["schaffen", "vollbringen", "vollenden", "leisten", "durchführen"]
}
File.open "file.yml", 'w:utf-8' do |f|
f << YAML.unescape(YAML.dump(input_for_yaml)).force_encoding("UTF-8")
end
p YAML.load_file("file.yml") # {:phonetic_notation=>"[ə’kɒmplɪʃ]", :words=>["schaffen", "vollbringen", "vollenden", "leisten", "durchführen"]}
# file.yml content
# ---
# :phonetic_notation: "[ə’kɒmplɪʃ]"
# :words:
# - schaffen
# - vollbringen
# - vollenden
# - leisten
# - "durchführen"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment