File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 5
5
class Buf does Positional { ... }
6
6
7
7
A C < Buf > (short for buffer) is a binary string, and generally returned from
8
- low-level IO operations. In the abstract it is just a list of integers, so
8
+ low-level IO operations or from C < Str.encode > . In the abstract it is just
9
+ a list of integers, so
9
10
for example indexing into a C < Buf > with C < .[$idx] > returns an C < Int > .
10
11
11
12
= head2 Methods
@@ -28,4 +29,10 @@ Returns C<False> if and only if the buffer is empty.
28
29
29
30
Returns the number of elements of the buffer.
30
31
32
+ = head3 decode
33
+
34
+ multi method decode(Buf:D: Str:D $encoding = 'UTF-8') returns Str:D
35
+
36
+ Applies an encoding to turn the buffer into a C < Str >
37
+
31
38
= end pod
Original file line number Diff line number Diff line change @@ -234,6 +234,14 @@ Examples:
234
234
multi sub substr(Str:D $s, Int:D $from, Int:D $chars = $s.chars - $from) returns Str:D
235
235
multi method substr(Str:D $s: Int:D $from, Int:D $chars = $s.chars - $from) returns Str:D
236
236
237
- TODO
237
+ Returns a part of the string, starting from the character with index C < $from >
238
+ (where the first character has index 0) and with length C < $chars > .
239
+
240
+ = head3 encode
241
+
242
+ multi method encode(Str:D: Str:D $encoding = 'UTF-8') returns Buf:D
243
+
244
+ Returns a buffer (ie a binary representation) of the string in the given
245
+ encoding.
238
246
239
247
= end pod
You can’t perform that action at this time.
0 commit comments