string.c: block for scrub with ASCII-incompatible
* string.c (rb_enc_str_scrub): honor the given block with ASCII-incompatible encoding. [ruby-core:79039] [Bug #13120] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e4a2dd5f52
commit
c763f0fb9b
6
string.c
6
string.c
@ -9345,7 +9345,11 @@ rb_enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl)
|
||||
const char *e = RSTRING_END(str);
|
||||
const char *p1 = p;
|
||||
long mbminlen = rb_enc_mbminlen(enc);
|
||||
if (!NIL_P(repl)) {
|
||||
if (rb_block_given_p()) {
|
||||
rep = NULL;
|
||||
replen = 0;
|
||||
}
|
||||
else if (!NIL_P(repl)) {
|
||||
rep = RSTRING_PTR(repl);
|
||||
replen = RSTRING_LEN(repl);
|
||||
}
|
||||
|
@ -1640,6 +1640,11 @@ class TestM17N < Test::Unit::TestCase
|
||||
assert_equal("\uFFFD".encode("UTF-32LE"),
|
||||
"\xff".force_encoding(Encoding::UTF_32LE).
|
||||
scrub)
|
||||
c = nil
|
||||
assert_equal("?".encode(Encoding::UTF_16LE),
|
||||
"\x00\xD8".force_encoding(Encoding::UTF_16LE).
|
||||
scrub {|e| c = e; "?".encode(Encoding::UTF_16LE)})
|
||||
assert_equal("\x00\xD8".force_encoding(Encoding::UTF_16LE), c)
|
||||
end
|
||||
|
||||
def test_scrub_dummy_encoding
|
||||
|
Loading…
x
Reference in New Issue
Block a user