Skip to content

Latest commit

 

History

History
101 lines (79 loc) · 2.7 KB

characters.md

File metadata and controls

101 lines (79 loc) · 2.7 KB

Characters

Characters are small numbers (aka enums) that may represent printed characters such as letters and digits, or not. The entire range of Unicode 15.0.0 (Sep 9, 2022) is supported.

Characters are written using the notation #\<character> or #\<character name> or #x<hex scalar value>.

The full list of character names:

#\null          ==>  #x0
#\alarm         ==>  #x7
#\backspace     ==>  #x8
#\tab           ==>  #x9
#\newline       ==>  #xA
#\return        ==>  #xD
#\escape        ==>  #x1B
#\space         ==>  #x20
#\delete        ==>  #x7F

char?,
char->integer, integer->char,
digit-value

char?

(char? obj), procedure

Returns #true if obj is a character (enum), otherwise returns #false.

(char? #\λ)             ==>  #true
(char? 100000)          ==>  #true
(char? #\space)         ==>  #true
(char? 1000000000000000000000000000000)  ==>  #false

char->integer

(char->integer char), procedure

Do nothing. Same as idf function.

(char->integer #\return)    ==> 13
(char->integer #\!)         ==> 33
(char->integer #\λ)         ==> 955

integer->char

(integer->char n), procedure

Do nothing. Same as idf function.

Note: If you want to see the unicode representation of a character, use the string function.

(integer->char 13)          ==> 13
(integer->char 33)          ==> 33
(integer->char 955)         ==> 955

(string 955)                ==> "λ"

digit-value

(digit-value char), procedure

This procedure returns the numeric value (0 to 9) of its argument if it is a numeric digit (that is, if char-numeric? returns #t), or #f on any other character.

(digit-value #\3)         ==>  3      ; 0033, DIGIT THREE
(digit-value #\٤)         ==>  4      ; 0664, ARABIC-INDIC DIGIT FOUR
(digit-value #\૦)         ==>  0      ; 0AE6, GUJARATI DIGIT ZERO
(digit-value #x0EA6)      ==>  #false ; not a Unicode character
(digit-value #\ʩ)         ==>  #false ; 02A9, LATIN SMALL LETTER FENG DIGRAPH
(digit-value #\Ⅽ)         ==>  #false ; 216D, ROMAN NUMERAL ONE HUNDRED