Created
February 24, 2012 19:03
-
-
Save tenderlove/1902995 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: shift_jis | |
require 'yaml' | |
hello = "こんにちは!" | |
string = "--- #{hello}" | |
# psych 1.2.2 で例外発生するけど、ruby trunk は例外発生しない: | |
loaded = YAML.load string | |
# これで psych 1.2.2 を使える: | |
loaded = YAML.load string.encode('UTF-8') | |
p loaded.encoding # => Encoding:UTF-8 | |
p loaded == hello # => false | |
Encoding.default_internal = Encoding::SHIFT_JIS | |
loaded = YAML.load string | |
p loaded.encoding # => Encoding:Shift_JIS | |
p loaded == hello # => true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment