Created
August 14, 2011 01:19
-
-
Save tenderlove/1144463 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
# coding: cp932 | |
gem 'psych', '~> 1.2.0' | |
require 'psych' | |
require 'yaml' | |
require 'minitest/autorun' | |
class TestEnc < MiniTest::Unit::TestCase | |
def setup | |
@oldenc = Encoding.default_internal | |
@v = {"a"=>"‚ "} | |
end | |
def teardown | |
Encoding.default_internal = @oldenc | |
end | |
def test_no_default | |
hash = YAML.load YAML.dump @v | |
assert_equal @v['a'], hash['a'].encode('CP932') | |
assert_equal @v['a'].encode('UTF-8'), hash['a'] | |
end | |
def test_with_default | |
Encoding.default_internal = Encoding::CP932 | |
hash = YAML.load YAML.dump @v | |
assert_equal @v['a'], hash['a'] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment