[前][次][番号順一覧][スレッド一覧]

ruby-changes:8488

From: nobu <ko1@a...>
Date: Wed, 29 Oct 2008 16:41:38 +0900 (JST)
Subject: [ruby-changes:8488] Ruby:r20021 (trunk): * pack.c (pack_pack): set encoding from packing string and UTF-8 for

nobu	2008-10-29 16:41:21 +0900 (Wed, 29 Oct 2008)

  New Revision: 20021

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20021

  Log:
    * pack.c (pack_pack): set encoding from packing string and UTF-8 for
      "U".  [ruby-core:19590]

  Modified files:
    trunk/ChangeLog
    trunk/pack.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 20020)
+++ ChangeLog	(revision 20021)
@@ -1,3 +1,8 @@
+Wed Oct 29 16:41:17 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@n...>
 
 	* complex.c (imp1, imp2): should declare type.
Index: pack.c
===================================================================
--- pack.c	(revision 20020)
+++ pack.c	(revision 20021)
@@ -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 @@
     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 @@
 		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 @@
 	    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];

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]