From fa127bbb189a88921870ccd922744a7aa14aa009 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 21 Oct 2008 15:52:07 +0000 Subject: * 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 --- string.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'string.c') 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()); -- cgit v1.2.3