mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/psych/lib/psych/nodes/node.rb: default to_yaml
encoding to be
UTF-8. * test/psych/test_encoding.rb: test yaml dump encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33052 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8b8c7fd386
commit
34f6671d68
3 changed files with 23 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
|||
Thu Aug 25 06:11:35 2011 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||
|
||||
* ext/psych/lib/psych/nodes/node.rb: default `to_yaml` encoding to be
|
||||
UTF-8.
|
||||
* test/psych/test_encoding.rb: test yaml dump encoding.
|
||||
|
||||
Thu Aug 25 01:24:33 2011 Naohisa Goto <ngotogenome@gmail.com>
|
||||
|
||||
* test/fileutils/test_fileutils.rb (test_chmod_symbol_mode): Solaris
|
||||
|
|
|
@ -41,7 +41,7 @@ module Psych
|
|||
#
|
||||
# See also Psych::Visitors::Emitter
|
||||
def to_yaml io = nil, options = {}
|
||||
real_io = io || StringIO.new
|
||||
real_io = io || StringIO.new(''.encode('utf-8'))
|
||||
|
||||
Visitors::Emitter.new(real_io, options).accept self
|
||||
return real_io.string unless io
|
||||
|
|
|
@ -40,6 +40,22 @@ module Psych
|
|||
assert_match(/alias value/, e.message)
|
||||
end
|
||||
|
||||
def test_to_yaml_is_valid
|
||||
ext_before = Encoding.default_external
|
||||
int_before = Encoding.default_internal
|
||||
|
||||
Encoding.default_external = Encoding::US_ASCII
|
||||
Encoding.default_internal = nil
|
||||
|
||||
s = "こんにちは!"
|
||||
# If no encoding is specified, use UTF-8
|
||||
assert_equal Encoding::UTF_8, Psych.dump(s).encoding
|
||||
assert_equal s, Psych.load(Psych.dump(s))
|
||||
ensure
|
||||
Encoding.default_external = ext_before
|
||||
Encoding.default_internal = int_before
|
||||
end
|
||||
|
||||
def test_start_mapping
|
||||
foo = 'foo'
|
||||
bar = 'バー'
|
||||
|
|
Loading…
Reference in a new issue