decodeLine

Decodes an UTF8 line from a Stream.

decodeLine
(
bool keepTerminator = false
)
in { assert (str !is null); }

Parameters

keepTerminator

Indicates wether the line ending is included in the result.

str
Type: Stream

The Stream to read.

Return Value

Type: auto

A dchar input range that represents a line.

Examples

1 import std.array: array;
2 auto text = "01\r\n23\n45\n".dup;
3 MemoryStream str = construct!MemoryStream();
4 scope(exit) destruct(str);
5 str.write(text.ptr, text.length);
6 str.position = 0;
7 auto _01 = str.decodeLine.array;
8 assert(_01 == "01");
9 auto _23 = str.decodeLine.array;
10 assert(_23 == "23");
11 auto _45 = str.decodeLine.array;
12 assert(_45 == "45");
13 auto term = str.decodeLine.array;
14 assert(term == "");

Meta