summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rw-r--r--pack.c6
2 files changed, 20 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 123d80238a..2bfe34b857 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+Tue Dec 9 11:50:46 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
+
+ * pack.c (pack_pck): fixed [ruby-dev:37295].
+ Array#pack always has returned an US-ASCII string when
+ the given format ended with 'u', 'M' or 'm'.
+
+Sat Dec 6 14:35:06 2008 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * pack.c (pack_pack): set US-ASCII and CODERANGE_7BIT
+ when quoted-printable ('M') and base64 ('m').
+ [ruby-dev:37284]
+
+ * pack.c (pack_unpack): ditto.
+
Thu Dec 11 11:51:36 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* encoding.c (rb_locale_encoding): removed Encoding::LOCALE.
diff --git a/pack.c b/pack.c
index c4ee6dbb30..119a83b1ae 100644
--- a/pack.c
+++ b/pack.c
@@ -896,6 +896,8 @@ pack_pack(VALUE ary, VALUE fmt)
case 'u': /* uuencoded string */
case 'm': /* base64 encoded string */
+ enc = rb_enc_compatible(res, rb_enc_from_encoding(rb_usascii_encoding()));
+ rb_enc_associate(res, enc);
from = NEXTFROM;
StringValue(from);
ptr = RSTRING_PTR(from);
@@ -924,6 +926,8 @@ pack_pack(VALUE ary, VALUE fmt)
break;
case 'M': /* quoted-printable encoded string */
+ enc = rb_enc_compatible(res, rb_enc_from_encoding(rb_usascii_encoding()));
+ rb_enc_associate(res, enc);
from = rb_obj_as_string(NEXTFROM);
if (len <= 1)
len = 72;
@@ -1886,6 +1890,7 @@ pack_unpack(VALUE str, VALUE fmt)
}
}
rb_str_set_len(buf, ptr - RSTRING_PTR(buf));
+ ENCODING_CODERANGE_SET(buf, rb_usascii_encindex(), ENC_CODERANGE_7BIT);
UNPACK_PUSH(buf);
}
break;
@@ -1914,6 +1919,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);
UNPACK_PUSH(buf);
}
break;