* ext/psych/parser.c (parse): Return strings encoded as

Encoding.default_internal if set.
* test/psych/test_encoding.rb: Tests for encoding change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tenderlove 2010-05-10 16:22:52 +00:00
parent 9d3b304b0b
commit 0de068d03e
3 changed files with 41 additions and 10 deletions

View file

@ -29,6 +29,22 @@ module Psych
@utf8 = Encoding.find('UTF-8')
end
def test_default_internal
before = Encoding.default_internal
Encoding.default_internal = 'EUC-JP'
str = "壁に耳あり、障子に目あり"
yaml = "--- #{str}"
assert_equal @utf8, str.encoding
@parser.parse str
assert_encodings Encoding.find('EUC-JP'), @handler.strings
assert_equal str, @handler.strings.first.encode('UTF-8')
ensure
Encoding.default_internal = before
end
def test_scalar
@parser.parse("--- a")
assert_encodings @utf8, @handler.strings