aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--string.c5
2 files changed, 8 insertions, 1 deletions
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 <naruse@ruby-lang.org>
+
+ * string.c (rb_str_substr): copy encoding although empty string.
+
Fri Feb 22 04:48:22 2008 NARUSE, Yui <naruse@ruby-lang.org>
* 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);
}