The chr routine

Combined from primary sources listed below.

In class Cool ( Type/Cool )§

See primary docmentation in context for routine chr.

routine chr§

sub chr(Int(Cool))
method chr()

Coerces the invocant (or in sub form, its argument) to Int, interprets it as a Unicode code points, and returns a Str made of that code point.

say '65'.chr;       # OUTPUT: «A␤»

The inverse operation is ord.

Mnemonic: turns an integer into a character.

In class Int ( Type/Int )§

See primary docmentation in context for routine chr.

routine chr§

multi        chr(Int:D  --> Str:D)
multi method chr(Int:D: --> Str:D)

Returns a one-character string, by interpreting the integer as a Unicode codepoint number and converting it to the corresponding character.

Example:

65.chr;  # returns "A"
196.chr# returns "Ä"