summaryrefslogtreecommitdiffstats
path: root/encoding.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-13 13:44:02 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-13 13:44:02 +0000
commit4249cbc9c825498200c2dfe68d647bd37353d52c (patch)
tree06dfcf6a2ac7c8db44196c02489aa209c5ead9b0 /encoding.c
parent642dc835fc232d4766bd5aa94c5de7bececa4edc (diff)
downloadruby-4249cbc9c825498200c2dfe68d647bd37353d52c.tar.gz
ruby-4249cbc9c825498200c2dfe68d647bd37353d52c.tar.xz
ruby-4249cbc9c825498200c2dfe68d647bd37353d52c.zip
* encoding.c (rb_enc_compatible): encoding should never fall back
to ASCII-8BIT unless both encodings are ASCII-8BIT. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'encoding.c')
-rw-r--r--encoding.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/encoding.c b/encoding.c
index 0562281d5..f297983cc 100644
--- a/encoding.c
+++ b/encoding.c
@@ -397,7 +397,10 @@ rb_enc_compatible(VALUE str1, VALUE str2)
if (cr1 == ENC_CODERANGE_7BIT) return rb_enc_from_index(idx2);
if (cr2 == ENC_CODERANGE_7BIT) return rb_enc_from_index(idx1);
}
- if (cr1 == ENC_CODERANGE_7BIT) return rb_enc_from_index(0);
+ if (cr2 == ENC_CODERANGE_7BIT) {
+ if (idx1 == 0) return rb_enc_from_index(idx2);
+ if (idx2 == 0) return rb_enc_from_index(idx1);
+ }
}
if (cr1 == ENC_CODERANGE_7BIT &&
rb_enc_asciicompat(enc = rb_enc_from_index(idx2)))