chr 
chr NUMBER
chrThis function returns the character represented by
NUMBER (truncated to an integer) in the
Unicode character set. For example, chr(65) is “A”, latin small
letter a, and chr(0x2122) is
“™”, trade
mark sign. For the reverse of chr, use ord.
If NUMBER is negative, this function
produces the Unicode replacement
character, U+FFFD.[235]
(Note that characters with codepoints between 128 and 255 are by default internally not encoded as UTF-8 for backward-compatibility reasons. You shouldn’t ever notice this, but if you do, that’s why.)
If you’d rather specify your characters by name than by number
(for example, “\N{WHITE SMILING
FACE}” for a Unicode smiley, “☺”), see the section charnames in Chapter 29. To convert a character
number to its official name instead of to the character itself, see that
pragma’s charnames::viacode
function.
[235] Except under the bytes
pragma, where the low eight bits of the value are used.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access