Created
January 22, 2010 07:50
-
-
Save tonini/283578 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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