summaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/string.c b/string.c
index 990694f24..7d6f30555 100644
--- a/string.c
+++ b/string.c
@@ -395,6 +395,9 @@ str_new(VALUE klass, const char *ptr, long len)
RSTRING(str)->as.heap.ptr = ALLOC_N(char,len+1);
STR_SET_NOEMBED(str);
}
+ else if (len == 0) {
+ ENC_CODERANGE_SET(str, ENC_CODERANGE_7BIT);
+ }
if (ptr) {
memcpy(RSTRING_PTR(str), ptr, len);
}