std/bytes¶
module bytes for Bytes : Index<Int>, Slice
The functions of a Bytes value, in the prelude. A receiver module:
b.size(), bytes.size(b) and b | size are one declaration. Bytes
implements Index<Int> and Slice through at and slice: b[0] is
b.at(0), the octet as an Int in 0..255, and b[0:12] is a Bytes.
at— The octet ofselfatposition, as anIntin0..255, ornoneoutside it; a negative position counts from the end:Bytes("hi").at(0)andBytes("hi")[0]are104.slice— The octets ofselffromstarttoend, clamped to its size; a negative bound counts from the end.size— How many octetsselfholds:Bytes("hé").size()is3.to_text—selfread as UTF-8 text, ornonewhere it is not valid UTF-8:Bytes("hé").to_text()issome("hé").