diff --git a/ChangeLog b/ChangeLog index e37cd0318b..94cb74ca96 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Feb 22 11:16:55 2008 NARUSE, Yui + + * string.c (rb_str_substr): copy encoding although empty string. + Fri Feb 22 04:48:22 2008 NARUSE, Yui * string.c (rb_str_times): empty string's coderange is CODERANGE_7BIT. diff --git a/string.c b/string.c index 34dccb27de..fbee097e06 100644 --- a/string.c +++ b/string.c @@ -1242,7 +1242,10 @@ rb_str_substr(VALUE str, long beg, long len) else { str2 = rb_str_new5(str, p, len); if (len) rb_enc_cr_str_copy(str2, str); - else ENC_CODERANGE_SET(str2, ENC_CODERANGE_7BIT); + else { + rb_enc_copy(str2, str); + ENC_CODERANGE_SET(str2, ENC_CODERANGE_7BIT); + } OBJ_INFECT(str2, str); }