Skip to content
Snippets Groups Projects
Commit d251be1e authored by Markus Reiter's avatar Markus Reiter
Browse files

Ensure `readline_nonblock` returns an UTF-8 string.

parent 625a950b
No related branches found
No related tags found
No related merge requests found
class IO
def readline_nonblock(sep = $INPUT_RECORD_SEPARATOR)
line = ""
buffer = ""
buffer.concat(read_nonblock(1)) while buffer[-1] != sep
buffer
loop do
break if buffer == sep
read_nonblock(1, buffer)
line.concat(buffer)
end
line
rescue IO::WaitReadable, EOFError => e
raise e if buffer.empty?
buffer
raise e if line.empty?
line
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment