mirror of
https://github.com/ruby/ruby.git
synced 2025-08-26 06:25:31 +02:00
[Bug #20924] Fix reading with delimiter in wide character encodings
This commit is contained in:
parent
3422bfcab6
commit
e90b447655
Notes:
git
2024-12-10 16:14:28 +00:00
2 changed files with 75 additions and 10 deletions
|
@ -2036,6 +2036,36 @@ class TestIO < Test::Unit::TestCase
|
|||
}
|
||||
end
|
||||
|
||||
def test_readline_limit_nonascii
|
||||
mkcdtmpdir do
|
||||
i = 0
|
||||
|
||||
File.open("text#{i+=1}", "w+:utf-8") do |f|
|
||||
f.write("Test\nok\u{bf}ok\n")
|
||||
f.rewind
|
||||
|
||||
assert_equal("Test\nok\u{bf}", f.readline("\u{bf}"))
|
||||
assert_equal("ok\n", f.readline("\u{bf}"))
|
||||
end
|
||||
|
||||
File.open("text#{i+=1}", "w+b:utf-32le") do |f|
|
||||
f.write("0123456789")
|
||||
f.rewind
|
||||
|
||||
assert_equal(4, f.readline(4).bytesize)
|
||||
assert_equal(4, f.readline(3).bytesize)
|
||||
end
|
||||
|
||||
File.open("text#{i+=1}", "w+:utf-8:utf-32le") do |f|
|
||||
f.write("0123456789")
|
||||
f.rewind
|
||||
|
||||
assert_equal(4, f.readline(4).bytesize)
|
||||
assert_equal(4, f.readline(3).bytesize)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_set_lineno_readline
|
||||
pipe(proc do |w|
|
||||
w.puts "foo"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue