* io.c (rb_io_ext_int_to_encs): ignore internal encoding if external
encoding is ASCII-8BIT. [Bug #8342] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ce573f3166
commit
4834aa5307
@ -1,3 +1,8 @@
|
|||||||
|
Wed May 8 17:43:55 2013 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
* io.c (rb_io_ext_int_to_encs): ignore internal encoding if external
|
||||||
|
encoding is ASCII-8BIT. [Bug #8342]
|
||||||
|
|
||||||
Wed May 8 13:49:38 2013 NARUSE, Yui <naruse@ruby-lang.org>
|
Wed May 8 13:49:38 2013 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* ext/json/generator/generator.c (isArrayOrObject): cast char to
|
* ext/json/generator/generator.c (isArrayOrObject): cast char to
|
||||||
|
4
NEWS
4
NEWS
@ -39,6 +39,10 @@ with all sufficient information, see the ChangeLog file.
|
|||||||
|
|
||||||
=== Core classes compatibility issues (excluding feature bug fixes)
|
=== Core classes compatibility issues (excluding feature bug fixes)
|
||||||
|
|
||||||
|
* IO
|
||||||
|
* incompatible changes:
|
||||||
|
* open ignore internal encoding if external encoding is ASCII-8BIT.
|
||||||
|
|
||||||
* Module#ancestors
|
* Module#ancestors
|
||||||
|
|
||||||
The ancestors of a singleton class now include singleton classes,
|
The ancestors of a singleton class now include singleton classes,
|
||||||
|
8
io.c
8
io.c
@ -4868,9 +4868,13 @@ rb_io_ext_int_to_encs(rb_encoding *ext, rb_encoding *intern, rb_encoding **enc,
|
|||||||
ext = rb_default_external_encoding();
|
ext = rb_default_external_encoding();
|
||||||
default_ext = 1;
|
default_ext = 1;
|
||||||
}
|
}
|
||||||
if (intern == NULL && ext != rb_ascii8bit_encoding())
|
if (ext == rb_ascii8bit_encoding()) {
|
||||||
/* If external is ASCII-8BIT, no default transcoding */
|
/* If external is ASCII-8BIT, no transcoding */
|
||||||
|
intern = NULL;
|
||||||
|
}
|
||||||
|
else if (intern == NULL) {
|
||||||
intern = rb_default_internal_encoding();
|
intern = rb_default_internal_encoding();
|
||||||
|
}
|
||||||
if (intern == NULL || intern == (rb_encoding *)Qnil ||
|
if (intern == NULL || intern == (rb_encoding *)Qnil ||
|
||||||
(!(fmode & FMODE_SETENC_BY_BOM) && (intern == ext))) {
|
(!(fmode & FMODE_SETENC_BY_BOM) && (intern == ext))) {
|
||||||
/* No internal encoding => use external + no transcoding */
|
/* No internal encoding => use external + no transcoding */
|
||||||
|
@ -105,6 +105,42 @@ EOT
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_open_r_ascii8bit
|
||||||
|
with_tmpdir {
|
||||||
|
generate_file('tmp', "")
|
||||||
|
EnvUtil.with_default_external(Encoding::ASCII_8BIT) do
|
||||||
|
EnvUtil.with_default_internal(Encoding::UTF_8) do
|
||||||
|
open("tmp", "r") {|f|
|
||||||
|
assert_equal(Encoding::ASCII_8BIT, f.external_encoding)
|
||||||
|
assert_equal(nil, f.internal_encoding)
|
||||||
|
}
|
||||||
|
open("tmp", "r:ascii-8bit") {|f|
|
||||||
|
assert_equal(Encoding::ASCII_8BIT, f.external_encoding)
|
||||||
|
assert_equal(nil, f.internal_encoding)
|
||||||
|
}
|
||||||
|
open("tmp", "r:ascii-8bit:utf-16") {|f|
|
||||||
|
assert_equal(Encoding::ASCII_8BIT, f.external_encoding)
|
||||||
|
assert_equal(nil, f.internal_encoding)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
EnvUtil.with_default_internal(nil) do
|
||||||
|
open("tmp", "r") {|f|
|
||||||
|
assert_equal(Encoding::ASCII_8BIT, f.external_encoding)
|
||||||
|
assert_equal(nil, f.internal_encoding)
|
||||||
|
}
|
||||||
|
open("tmp", "r:ascii-8bit") {|f|
|
||||||
|
assert_equal(Encoding::ASCII_8BIT, f.external_encoding)
|
||||||
|
assert_equal(nil, f.internal_encoding)
|
||||||
|
}
|
||||||
|
open("tmp", "r:ascii-8bit:utf-16") {|f|
|
||||||
|
assert_equal(Encoding::ASCII_8BIT, f.external_encoding)
|
||||||
|
assert_equal(nil, f.internal_encoding)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def test_open_r_enc_in_opt
|
def test_open_r_enc_in_opt
|
||||||
with_tmpdir {
|
with_tmpdir {
|
||||||
generate_file('tmp', "")
|
generate_file('tmp', "")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user