Ensure readline_nonblock
returns an UTF-8 string.
This commit is contained in:
parent
625a950b46
commit
d251be1eeb
@ -1,10 +1,17 @@
|
|||||||
class IO
|
class IO
|
||||||
def readline_nonblock(sep = $INPUT_RECORD_SEPARATOR)
|
def readline_nonblock(sep = $INPUT_RECORD_SEPARATOR)
|
||||||
|
line = ""
|
||||||
buffer = ""
|
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
|
rescue IO::WaitReadable, EOFError => e
|
||||||
raise e if buffer.empty?
|
raise e if line.empty?
|
||||||
buffer
|
line
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user