diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-11-30 16:47:24 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-11-30 16:47:24 +0000 |
commit | 05d7d889ea4034ed2ee6fec8e9ddd6256b72065b (patch) | |
tree | e6be44b5a5fbda1ccbd8d95295146055fc00059a /test/ruby | |
parent | 87703540b03e31d3d34a0645b2e03011471f4167 (diff) | |
download | ruby-05d7d889ea4034ed2ee6fec8e9ddd6256b72065b.tar.gz |
* string.c (rb_str_inspect): inspect as a dummy encoding string
when a UTF-16/32 (not BE/LE) string does not have a BOM.
Unicode and some RFCs say that a string labeld as UTF-16/32
doesn't have a BOM, it should be considered big endian.
But many Windows programs generates little endian UTF-16
strings without a BOM. So String#inspect treats a string
labeled UTF-16/32 withaout a BOM as a dummy encoding string.
patched by Martin Duerst. [ruby-core:33461]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_m17n.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb index 3dccc76c91..cfe7ed4d3d 100644 --- a/test/ruby/test_m17n.rb +++ b/test/ruby/test_m17n.rb @@ -232,6 +232,19 @@ class TestM17N < Test::Unit::TestCase Encoding.default_external = orig_ext end + def test_utf_16_32_inspect + str = "\u3042" + %w/UTF-16 UTF-32/.each do |enc| + %w/BE LE/.each do |endian| + s = str.encode(enc + endian) + # When a UTF-16/32 string doesn't have a BOM, + # inspect as a dummy encoding string. + assert_equal(s.dup.force_encoding("ISO-2022-JP").inspect, + s.dup.force_encoding(enc).inspect) + end + end + end + def test_str_dump [ e("\xfe"), |