Create a gist now

Instantly share code, notes, and snippets.

# encoding: shift_jis
require 'yaml'
require 'tempfile'
t = Tempfile.new(['shiftjis', 'yml'], :encoding => 'SHIFT_JIS')
t.write '--- こんにちは!'
t.close
# If the external encoding isn't utf8, utf16le, or utf16be, we cannot
# process the file.
File.open(t.path, 'r', :encoding => 'SHIFT_JIS') do |f|
YAML.load(f) # ArgumentError が例外発生する
end
t.close(true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment