summaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-07 03:45:12 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-07 03:45:12 +0000
commitb5d63bec8fbdbd06b4e145ee1a565c238e2d6799 (patch)
tree40b9ce2dae35a99bab2369a11e0b2f1c0eccc78a /io.c
parent1b1cedb02233863c5f13803de9bcd990804a4f54 (diff)
downloadruby-b5d63bec8fbdbd06b4e145ee1a565c238e2d6799.tar.gz
ruby-b5d63bec8fbdbd06b4e145ee1a565c238e2d6799.tar.xz
ruby-b5d63bec8fbdbd06b4e145ee1a565c238e2d6799.zip
* io.c (make_writeconv): choose ASCII compatible encoding as
intermediate encoding if stateful encoder exists. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/io.c b/io.c
index 5c43a062d..b7a531498 100644
--- a/io.c
+++ b/io.c
@@ -729,6 +729,14 @@ make_writeconv(rb_io_t *fptr)
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);