readln

Reads a line in a Stream, without decoding.

Content is assumed to be encoded in UTF-8.

const(char)[]
readln
(
bool keepTerminator = false
size_t buffLen = 64
)
in { assert (str !is null); }

Parameters

keepTerminator

Indicates wether the line ending is included in the result.

buffLen

The buffer length, by default 64.

str
Type: Stream

The Stream where a line is read.

Return Value

Type: const(char)[]

An array of char.

Examples

1 auto text = "01\r\n23\n4à\n".dup;
2 MemoryStream str = construct!MemoryStream();
3 scope(exit) destruct(str);
4 str.write(text.ptr, text.length);
5 str.position = 0;
6 const _01 = str.readln;
7 assert(_01 == "01", _01);
8 const _23 = str.readln;
9 assert(_23 == "23");
10 const _45 = str.readln;
11 assert(_45 == "4à");
12 const term = str.readln;
13 assert(term == "", term);

Meta