In Cool§

See primary documentation in context for routine ords

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. If you are only interested in the number of codepoints, codes is a possibly faster option.

In Nil§

See primary documentation in context for method ords

Returns an empty Seq, but will also issue a warning depending on the context it's used (for instance, a warning about using it in string context if used with say).

In Str§

See primary documentation in context for method ords

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

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

Example:

"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; codes computes the codepoints in a different way, so the result might be faster.

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