summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--pack.c2
-rw-r--r--test/ruby/test_pack.rb2
3 files changed, 8 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 79a0790867..0d27505070 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Jan 14 14:01:12 2011 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * pack.c (pack_unpack): the resulted string of unpack('M') must have
+ ASCII-8BIT encoding (and ENC_CODERANGE_VALID). [ruby-core:34482]
+
Fri Jan 14 13:38:58 2011 NARUSE, Yui <naruse@ruby-lang.org>
* ext/zlib/zlib.c (gzfile_check_footer): ISIZE (Input SIZE) in
diff --git a/pack.c b/pack.c
index 7031b45092..be454f2745 100644
--- a/pack.c
+++ b/pack.c
@@ -2024,7 +2024,7 @@ pack_unpack(VALUE str, VALUE fmt)
s++;
}
rb_str_set_len(buf, ptr - RSTRING_PTR(buf));
- ENCODING_CODERANGE_SET(buf, rb_usascii_encindex(), ENC_CODERANGE_7BIT);
+ ENCODING_CODERANGE_SET(buf, rb_ascii8bit_encindex(), ENC_CODERANGE_VALID);
UNPACK_PUSH(buf);
}
break;
diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb
index a668f7b218..054fa82567 100644
--- a/test/ruby/test_pack.rb
+++ b/test/ruby/test_pack.rb
@@ -570,6 +570,8 @@ class TestPack < Test::Unit::TestCase
assert_equal(["\x0a"], "=0A=\n".unpack("M"))
assert_equal([""], "=0Z=\n".unpack("M"))
assert_equal([""], "=\r\n".unpack("M"))
+ assert_equal([""], "=\r\n".unpack("M"))
+ assert_equal(["\xC6\xF7"], "=C6=F7".unpack('M*'))
end
def test_pack_unpack_P2