* string.c (rb_str_concat): set ENC_CODERANGE_VALID when the
receiver is 7BIT and the argument is non ASCII. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d9615bf9c5
commit
3002e5e1f9
@ -1,3 +1,8 @@
|
|||||||
|
Mon Nov 22 11:58:11 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
* string.c (rb_str_concat): set ENC_CODERANGE_VALID when the
|
||||||
|
receiver is 7BIT and the argument is non ASCII.
|
||||||
|
|
||||||
Mon Nov 22 01:48:58 2010 Tadayoshi Funaba <tadf@dotrb.org>
|
Mon Nov 22 01:48:58 2010 Tadayoshi Funaba <tadf@dotrb.org>
|
||||||
|
|
||||||
* lib/date.rb: some improvements for performance.
|
* lib/date.rb: some improvements for performance.
|
||||||
|
2
string.c
2
string.c
@ -2043,6 +2043,8 @@ rb_str_concat(VALUE str1, VALUE str2)
|
|||||||
}
|
}
|
||||||
rb_str_resize(str1, pos+len);
|
rb_str_resize(str1, pos+len);
|
||||||
rb_enc_mbcput(lc, RSTRING_PTR(str1)+pos, enc);
|
rb_enc_mbcput(lc, RSTRING_PTR(str1)+pos, enc);
|
||||||
|
if (cr == ENC_CODERANGE_7BIT && lc > 127)
|
||||||
|
cr = ENC_CODERANGE_VALID;
|
||||||
ENC_CODERANGE_SET(str1, cr);
|
ENC_CODERANGE_SET(str1, cr);
|
||||||
return str1;
|
return str1;
|
||||||
}
|
}
|
||||||
|
@ -1102,6 +1102,7 @@ class TestM17N < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_str_concat
|
def test_str_concat
|
||||||
|
assert_equal(1, "".concat(0xA2))
|
||||||
assert_equal("A\x84\x31\xA4\x39".force_encoding("GB18030"),
|
assert_equal("A\x84\x31\xA4\x39".force_encoding("GB18030"),
|
||||||
"A".force_encoding("GB18030") << 0x8431A439)
|
"A".force_encoding("GB18030") << 0x8431A439)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user