summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-23 07:10:56 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-23 07:10:56 +0000
commit1046eae7814930fb326371930715122d647457a2 (patch)
tree6efdbbf0c9fb2ddc397568769d80f3f7242e237d /test
parentdee6a910024e119b6064031487f87d927d960304 (diff)
io.c: read BOM only for reading
* io.c (io_strip_bom): just abandon detecting UTF encoding by BOM unless opened for reading. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_io_m17n.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb
index ccb124a46b..8ba34845fa 100644
--- a/test/ruby/test_io_m17n.rb
+++ b/test/ruby/test_io_m17n.rb
@@ -2168,6 +2168,20 @@ EOT
assert_nil(enc)
end
+ def test_bom_non_reading
+ with_tmpdir {
+ enc = nil
+ assert_nothing_raised(IOError) {
+ open("test", "w:bom|utf-8") {|f|
+ enc = f.external_encoding
+ f.print("abc")
+ }
+ }
+ assert_equal(Encoding::UTF_8, enc)
+ assert_equal("abc", File.binread("test"))
+ }
+ end
+
def test_cbuf
with_tmpdir {
fn = "tst"