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

ruby-changes:7689

From: akr <ko1@a...>
Date: Sun, 7 Sep 2008 12:45:39 +0900 (JST)
Subject: [ruby-changes:7689] Ruby:r19210 (trunk): * io.c (make_writeconv): choose ASCII compatible encoding as

akr	2008-09-07 12:45:12 +0900 (Sun, 07 Sep 2008)

  New Revision: 19210

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

  Log:
    * io.c (make_writeconv): choose ASCII compatible encoding as
      intermediate encoding if stateful encoder exists.

  Modified files:
    trunk/ChangeLog
    trunk/io.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 19209)
+++ ChangeLog	(revision 19210)
@@ -1,3 +1,8 @@
+Sun Sep  7 12:44:26 2008  Tanaka Akira  <akr@f...>
+
+	* io.c (make_writeconv): choose ASCII compatible encoding as
+	  intermediate encoding if stateful encoder exists.
+
 Sun Sep  7 12:09:29 2008  Tanaka Akira  <akr@f...>
 
 	* include/ruby/encoding.h (ECONV_XML_ATTR_CONTENT_ENCODER): defined.
Index: io.c
===================================================================
--- io.c	(revision 19209)
+++ io.c	(revision 19210)
@@ -729,6 +729,14 @@
                     denc = enc->name;
                     fptr->writeconv_stateless = rb_str_new2(senc);
                 }
+                else if ((fptr->encs.ecflags & ECONV_STATEFUL_ENCODER_MASK) && !rb_enc_asciicompat(enc)) {
+                    /* xxx: stateful encoder works for ASCII compatible encoding.
+                     * So we need to choose an encoding which is ASCII compatible and superset of enc.
+                     * For encodings which is superset of UTF-8, UTF-8 is not appropriate choice.  */
+                    senc = "UTF-8";
+                    denc = enc->name;
+                    fptr->writeconv_stateless = rb_str_new2("UTF-8");
+                }
                 else {
                     senc = denc = "";
                     fptr->writeconv_stateless = rb_str_new2(enc->name);

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

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