Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- # encoding: utf-8
- require 'yaml'
- require 'syck'
- require 'syck/encoding'
- YAML::ENGINE.yamler = "syck"
- class Bar
- def initialize
- @pow = "pöw - this is utf-8, no problem"
- @bar = "bär".force_encoding('ascii-8bit')
- end
- end
- class Foo
- def initialize
- #@foo = "föö"
- @foo = "föö".force_encoding('ascii-8bit')
- @bar = Bar.new
- @baz = [
- Bar.new,
- ]
- end
- end
- test = ["Grüße", "Öl", "Käse", Foo.new]
- yaml = YAML.dump(test)
- puts yaml
- puts
- puts Syck.unescape(yaml)
Add Comment
Please, Sign In to add comment