* 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
This commit is contained in:
parent
2100e3b631
commit
34c5cea9b5
@ -1,3 +1,8 @@
|
|||||||
|
Wed Oct 29 16:41:17 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* pack.c (pack_pack): set encoding from packing string and UTF-8 for
|
||||||
|
"U". [ruby-core:19590]
|
||||||
|
|
||||||
Wed Oct 29 15:50:00 2008 TAKANO Mitsuhiro (takano32) <tak@no32.tk>
|
Wed Oct 29 15:50:00 2008 TAKANO Mitsuhiro (takano32) <tak@no32.tk>
|
||||||
|
|
||||||
* complex.c (imp1, imp2): should declare type.
|
* complex.c (imp1, imp2): should declare type.
|
||||||
|
6
pack.c
6
pack.c
@ -10,6 +10,7 @@
|
|||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
#include "ruby/ruby.h"
|
#include "ruby/ruby.h"
|
||||||
|
#include "ruby/encoding.h"
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -443,6 +444,7 @@ pack_pack(VALUE ary, VALUE fmt)
|
|||||||
char type;
|
char type;
|
||||||
long items, len, idx, plen;
|
long items, len, idx, plen;
|
||||||
const char *ptr;
|
const char *ptr;
|
||||||
|
rb_encoding *enc;
|
||||||
#ifdef NATINT_PACK
|
#ifdef NATINT_PACK
|
||||||
int natint; /* native integer */
|
int natint; /* native integer */
|
||||||
#endif
|
#endif
|
||||||
@ -517,6 +519,8 @@ pack_pack(VALUE ary, VALUE fmt)
|
|||||||
ptr = RSTRING_PTR(from);
|
ptr = RSTRING_PTR(from);
|
||||||
plen = RSTRING_LEN(from);
|
plen = RSTRING_LEN(from);
|
||||||
OBJ_INFECT(res, from);
|
OBJ_INFECT(res, from);
|
||||||
|
enc = rb_enc_compatible(res, from);
|
||||||
|
rb_enc_associate(res, enc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p[-1] == '*')
|
if (p[-1] == '*')
|
||||||
@ -865,6 +869,8 @@ pack_pack(VALUE ary, VALUE fmt)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'U': /* Unicode character */
|
case 'U': /* Unicode character */
|
||||||
|
enc = rb_enc_compatible(res, rb_enc_from_encoding(rb_utf8_encoding()));
|
||||||
|
rb_enc_associate(res, enc);
|
||||||
while (len-- > 0) {
|
while (len-- > 0) {
|
||||||
SIGNED_VALUE l;
|
SIGNED_VALUE l;
|
||||||
char buf[8];
|
char buf[8];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user