aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/string.c b/string.c
index 9238e6c7f8..d724a28f2b 100644
--- a/string.c
+++ b/string.c
@@ -1925,10 +1925,11 @@ rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len,
str_cr = ENC_CODERANGE(str);
if (str_encindex == ptr_encindex) {
- if (str_cr == ENC_CODERANGE_UNKNOWN ||
- (ptr_a8 && str_cr != ENC_CODERANGE_7BIT)) {
+ if (str_cr == ENC_CODERANGE_UNKNOWN)
ptr_cr = ENC_CODERANGE_UNKNOWN;
- }
+ else if (ptr_a8 && str_cr == ENC_CODERANGE_VALID)
+ /* since str is also ASCII-8BIT, 7bit nor unknown means valid */
+ ptr_cr = ENC_CODERANGE_VALID;
else if (ptr_cr == ENC_CODERANGE_UNKNOWN) {
ptr_cr = coderange_scan(ptr, len, rb_enc_from_index(ptr_encindex));
}