summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-21 15:52:07 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-21 15:52:07 +0000
commitfa127bbb189a88921870ccd922744a7aa14aa009 (patch)
tree227ea073e4e889b0e081a5888ec61c4f669314d9 /string.c
parent73e221a1be7eca8b604992f84009829793d77e6c (diff)
* string.c (rb_external_str_new_with_enc): wrong condition to
calculate strlen(). * ext/readline/readline.c: add encoding support. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/string.c b/string.c
index 76f9c8d147..b637d38fb4 100644
--- a/string.c
+++ b/string.c
@@ -484,7 +484,8 @@ rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
if (!to) return str;
if (from == to) return str;
- if (rb_enc_asciicompat(to) && ENC_CODERANGE(str) == ENC_CODERANGE_7BIT) {
+ if ((rb_enc_asciicompat(to) && ENC_CODERANGE(str) == ENC_CODERANGE_7BIT) ||
+ to == rb_ascii8bit_encoding()) {
if (STR_ENC_GET(str) != to) {
str = rb_str_dup(str);
rb_enc_associate(str, to);
@@ -528,7 +529,7 @@ rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *eenc)
{
VALUE str;
- if (len == 0 && !ptr) len = strlen(ptr);
+ if (len == 0 && ptr) len = strlen(ptr);
str = rb_tainted_str_new(ptr, len);
rb_enc_associate(str, eenc);
return rb_str_conv_enc(str, eenc, rb_default_internal_encoding());