From a648fc802bd626dc29ec690f29c6a69f2510b0cb Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 13 Dec 2007 13:44:02 +0000 Subject: * encoding.c (rb_enc_compatible): encoding should never fall back to ASCII-8BIT unless both encodings are ASCII-8BIT. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- encoding.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'encoding.c') diff --git a/encoding.c b/encoding.c index 0562281d51..f297983cc2 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))) -- cgit v1.2.3