Characters
Like C or Java, but unlike Python, Julia implements a type for a single character, the Char type. A character literal is written as 'A', typeof('A') returns Char. A Char type is, in fact, a 32-bit integer whose numeric value is a Unicode code point, and they range from '\0' to '\Uffffffff'. Convert this to its code point with int(): int('A') returns 65, int('α') returns 945, so this takes two bytes.
The reverse also works: char(65) returns 'A', char(945) returns '\u3b1', the code point for α (3b1 is hexadecimal for 945).
Unicode characters can be entered by a \u in single quotes, followed by four hexadecimal digits (0-9, A-F), or \U followed by eight hexadecimal digits. The function is_valid_char() can test whether a number returns an ...
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