Documentation for routine ords

Documentation for routine ords, assembled from the following types:

class Cool

From Cool

(Cool) routine ords

Defined as:

sub ords(Str(Cool$str)
method ords()

Coerces the invocant (or in the sub form, the first argument) to Str, and returns a list of Unicode codepoints for each character.

say "Camelia".ords;              # OUTPUT: «67 97 109 101 108 105 97␤» 
say ords 10;                     # OUTPUT: «49 48␤» 

This is the list-returning version of ord. The inverse operation in chrs.

class Str

From Str

(Str) method ords

multi method ords(Str:D: --> Positional)

Returns a list of Unicode codepoint numbers that describe the codepoints making up the string.


"aå«".ords# (97 229 171) 

Strings are represented as graphemes. If a character in the string is represented by multiple codepoints, then all of those codepoints will appear in the result of ords. Therefore, the number of elements in the result may not always be equal to chars, but will be equal to codes.

The codepoints returned will represent the string in NFC. See the NFD, NFKC, and NFKD methods if other forms are required.