Guest User

Untitled

a guest
Nov 17th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. # encoding: utf-8
  3.  
  4. require 'yaml'
  5. require 'syck'
  6. require 'syck/encoding'
  7. YAML::ENGINE.yamler = "syck"
  8.  
  9. class Bar
  10. def initialize
  11. @pow = "pöw - this is utf-8, no problem"
  12. @bar = "bär".force_encoding('ascii-8bit')
  13. end
  14. end
  15. class Foo
  16. def initialize
  17. #@foo = "föö"
  18. @foo = "föö".force_encoding('ascii-8bit')
  19. @bar = Bar.new
  20. @baz = [
  21. Bar.new,
  22. ]
  23. end
  24. end
  25.  
  26. test = ["Grüße", "Öl", "Käse", Foo.new]
  27. yaml = YAML.dump(test)
  28.  
  29. puts yaml
  30. puts
  31. puts Syck.unescape(yaml)
Add Comment
Please, Sign In to add comment