diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-29 07:41:21 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-29 07:41:21 +0000 |
commit | 34c5cea9b52b7289b45ebc801a886ca8ecb613b2 (patch) | |
tree | 0695f21b1c564bbc8287cfaab21af0d38145ab62 /pack.c | |
parent | 2100e3b631edd4de13d272902d8330d6a64fa5a2 (diff) | |
download | ruby-34c5cea9b52b7289b45ebc801a886ca8ecb613b2.tar.gz |
* pack.c (pack_pack): set encoding from packing string and UTF-8 for
"U". [ruby-core:19590]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'pack.c')
-rw-r--r-- | pack.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -10,6 +10,7 @@ **********************************************************************/ #include "ruby/ruby.h" +#include "ruby/encoding.h" #include <sys/types.h> #include <ctype.h> #include <errno.h> @@ -443,6 +444,7 @@ pack_pack(VALUE ary, VALUE fmt) char type; long items, len, idx, plen; const char *ptr; + rb_encoding *enc; #ifdef NATINT_PACK int natint; /* native integer */ #endif @@ -517,6 +519,8 @@ pack_pack(VALUE ary, VALUE fmt) ptr = RSTRING_PTR(from); plen = RSTRING_LEN(from); OBJ_INFECT(res, from); + enc = rb_enc_compatible(res, from); + rb_enc_associate(res, enc); } if (p[-1] == '*') @@ -865,6 +869,8 @@ pack_pack(VALUE ary, VALUE fmt) break; case 'U': /* Unicode character */ + enc = rb_enc_compatible(res, rb_enc_from_encoding(rb_utf8_encoding())); + rb_enc_associate(res, enc); while (len-- > 0) { SIGNED_VALUE l; char buf[8]; |