Skip to content

Commit db99244

Browse files
committed
[S15] Change .chr(s) to return Uni, not Str.
This is because Uni is the only string type that won't convert strings given to it, which for people who are playing with numeric arrays of codepoints is probably important.
1 parent c834ab1 commit db99244

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

S15-unicode.pod

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,11 @@ type C<Str> may return invalid negative numbers as "codepoints".
303303
304304
=head2 Character Representation
305305
306-
chr(Int $codepoint) --> Str
307-
chrs(Array[Int] @codepoints) --> Str
306+
chr(Int $codepoint) --> Uni
307+
chrs(Array[Int] @codepoints) --> Uni
308308
309-
Cool.chr() --> Str
310-
Cool.chrs() --> Str
309+
Cool.chr() --> Uni
310+
Cool.chrs() --> Uni
311311
312312
Converts one or more numbers into a series of characters, treating those numbers
313313
as Unicode codepoints. The C<chrs> version generates a multi-character string
@@ -316,13 +316,12 @@ from the given array.
316316
Note that this operates on encoding-independent codepoints (use C<Buf> types for
317317
encoded codepoints).
318318
319-
An error will occur if the C<Str> generated by these functions contains an
319+
An error will occur if the C<Uni> generated by these functions contains an
320320
invalid character or sequence of characters. This includes, but is not limited
321-
to, codepoint values greater than C<0x10FFFF> and parts of surrogate code pairs,
322-
and negative numbers.
321+
to, codepoint values greater than C<0x10FFFF> and parts of surrogate code pairs.
323322
324-
The ability to convert negative number codepoints (i.e. C<Str.ords>) is not
325-
guaranteed and therefore currently disallowed.
323+
To obtain a more definitive string type, the normal ways of type conversion may
324+
be used.
326325
327326
=head2 Character Name
328327

0 commit comments

Comments
 (0)