Skip to content

Commit e020cb1

Browse files
committed
[S15] Fix ord(s) to work on all Stringy.
This presumes that Unicodey does Stringy. If not, then you simply need to add the signatures for Unicodey things where these changes were made. Additionally, some clarification on .chr(s).
1 parent f4b1200 commit e020cb1

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

S15-unicode.pod

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -290,19 +290,20 @@ C<Hash>.
290290
291291
=head2 Numeric Codepoint
292292
293-
ord(Str $char) --> Int
294-
ords(Str $string) --> Array[Int]
293+
ord(Stringy $char) --> Int
294+
ords(Stringy $string) --> Array[Int]
295295
296-
Str.ord() --> Int
297-
Str.ords() --> Array[Int]
296+
Stringy.ord() --> Int
297+
298+
Stringy.ords() --> Array[Int]
298299
299-
The C<&ord> function (and corresponding C<Str.ord> method) return the codepoint
300-
number of the first codepoint of the string. The C<&ords> function and method
301-
returns an C<Array> of codepoint numbers for every codepoint in the string.
300+
The C<&ord> function (and corresponding C<Stringy.ord> method) return the
301+
codepoint number of the first codepoint of the string. The C<&ords> function and
302+
method returns an C<Array> of codepoint numbers for every codepoint in the
303+
string.
302304
303-
[Conjecture: should there be a C<:raw> adverb or C<&raword> function that allows
304-
you to access NFG codepoints, i.e. get negative numbers? Seems useless given how
305-
those numbers work, but you never know...]
305+
This works on any type that does the C<Stringy> role. Note that using this on
306+
type C<Str> may return invalid negative numbers as "codepoints".
306307
307308
=head2 Character Representation
308309
@@ -321,7 +322,11 @@ encoded codepoints).
321322
322323
An error will occur if the C<Str> generated by these functions contains an
323324
invalid character or sequence of characters. This includes, but is not limited
324-
to, codepoint values greater than C<0x10FFFF> and parts of surrogate code pairs.
325+
to, codepoint values greater than C<0x10FFFF> and parts of surrogate code pairs,
326+
and negative numbers.
327+
328+
The ability to convert negative number codepoints (i.e. C<Str.ords>) is not
329+
guaranteed and therefore currently disallowed.
325330
326331
=head2 Character Name
327332

0 commit comments

Comments
 (0)