The line terminator '\n' and '\r\n', if any, is removed in each line.
var txt = "Hello\n\nWorld\n"
var i = new StringReader(txt)
assert i.read_line == "Hello"
assert i.read_line == ""
assert i.read_line == "World"
assert i.eof
Only LINE FEED (\n), CARRIAGE RETURN & LINE FEED (\r\n), and
the end or file (EOF) is considered to delimit the end of lines.
CARRIAGE RETURN (\r) alone is not used for the end of line.
var txt2 = "Hello\r\n\n\rWorld"
var i2 = new StringReader(txt2)
assert i2.read_line == "Hello"
assert i2.read_line == ""
assert i2.read_line == "\rWorld"
assert i2.eof
NOTE: Use append_line_to if the line terminator needs to be preserved.
# Read a string until the end of the line.
#
# The line terminator '\n' and '\r\n', if any, is removed in each line.
#
# ~~~
# var txt = "Hello\n\nWorld\n"
# var i = new StringReader(txt)
# assert i.read_line == "Hello"
# assert i.read_line == ""
# assert i.read_line == "World"
# assert i.eof
# ~~~
#
# Only LINE FEED (`\n`), CARRIAGE RETURN & LINE FEED (`\r\n`), and
# the end or file (EOF) is considered to delimit the end of lines.
# CARRIAGE RETURN (`\r`) alone is not used for the end of line.
#
# ~~~
# var txt2 = "Hello\r\n\n\rWorld"
# var i2 = new StringReader(txt2)
# assert i2.read_line == "Hello"
# assert i2.read_line == ""
# assert i2.read_line == "\rWorld"
# assert i2.eof
# ~~~
#
# NOTE: Use `append_line_to` if the line terminator needs to be preserved.
fun read_line: String
do
if last_error != null then return ""
if eof then return ""
var s = new FlatBuffer
append_line_to(s)
return s.to_s.chomp
end
lib/core/stream.nit:249,2--283,4