Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
# 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
Something went wrong with that request. Please try again.