From 0fc0d3820368ad2ec11b4449c2841d87f986c0fd Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 31 Jul 2009 20:36:04 +0000 Subject: Can't use singlebyte optimization when the replacement is multibyte. [ruby-core:24612] * string.c (tr_trans): can't use singlebyte optimization when the replacement is multibyte. [ruby-core:24612] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@24342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- string.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'string.c') diff --git a/string.c b/string.c index 34f35b8b2..6e6db0053 100644 --- a/string.c +++ b/string.c @@ -4871,7 +4871,8 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag) if (r == errc) r = trrepl.now; if (c < 256) { trans[c] = r; - if (r > 255) singlebyte = 0; + if (r > 255 || (r > 127 && rb_enc_mbmaxlen(enc) != 1)) + singlebyte = 0; } else { if (!hash) hash = rb_hash_new(); -- cgit