summaryrefslogtreecommitdiff
path: root/test/ruby/test_io_m17n.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-13 09:48:27 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-13 09:48:27 +0000
commitb861d5473cfa1f3aa64979d9ff0655230eea9a14 (patch)
treebbe2feebe5fd95bf5081846fff9be917cefe2339 /test/ruby/test_io_m17n.rb
parentce6f0e36a3107e4d78f8b508581cebbc9c8dd0f7 (diff)
io.c: BOM with non-UTF
* io.c (io_encname_bom_p): check BOM prefix only, not including UTF prefix. * io.c (parse_mode_enc): warn BOM with non-UTF encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_io_m17n.rb')
-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 63eb4b7d88d..fb99c0cd6d5 100644
--- a/test/ruby/test_io_m17n.rb
+++ b/test/ruby/test_io_m17n.rb
@@ -2095,6 +2095,20 @@ EOT
end;
end
+ def test_bom_non_utf
+ enc = nil
+
+ assert_warn(/BOM/) {
+ open(__FILE__, "r:bom|us-ascii") {|f| enc = f.external_encoding}
+ }
+ assert_equal(Encoding::US_ASCII, enc)
+
+ assert_warn(/BOM/) {
+ open(IO::NULL, "w:bom|us-ascii") {|f| enc = f.external_encoding}
+ }
+ assert_equal(Encoding::US_ASCII, enc)
+ end
+
def test_cbuf
with_tmpdir {
fn = "tst"