Next: , Previous: , Up: Characters   [Contents][Index]


5.1 Character implementation

An MIT/GNU Scheme character consists of a code part and a bucky bits part. The code part is a Unicode code point, while the bucky bits are an additional set of bits representing shift keys available on some keyboards.

There are 4 bucky bits, named control, meta, super, and hyper. On GNU/Linux systems running a graphical desktop, the control bit corresponds to the CTRL key; the meta bit corresponds to the ALT key; and the super bit corresponds to the “windows” key. On macOS, these are the CONTROL, OPTION, and COMMAND keys respectively.

Characters with bucky bits are not used much outside of graphical user interfaces (e.g. Edwin). They cannot be stored in strings or character sets, and aren’t read or written by textual I/O ports.

procedure: make-char code bucky-bits

Builds a character from code and bucky-bits. The value of code must be a Unicode code point; the value of bucky-bits must be an exact non-negative integer strictly less than 16. If 0 is specified for bucky-bits, make-char produces an ordinary character; otherwise, the appropriate bits are set as follows:

1               meta
2               control
4               super
8               hyper

For example,

(make-char 97 0)                        ⇒  #\a
(make-char 97 1)                        ⇒  #\M-a
(make-char 97 2)                        ⇒  #\C-a
(make-char 97 3)                        ⇒  #\C-M-a
procedure: char-code char

Returns the Unicode code point of char. Note that if char has no bucky bits set, then this is the same value returned by char->integer.

For example,

(char-code #\a)                         ⇒  97
(char-code #\c-a)                       ⇒  97
procedure: char-bits char

Returns the exact integer representation of char’s bucky bits. For example,

(char-bits #\a)                         ⇒  0
(char-bits #\m-a)                       ⇒  1
(char-bits #\c-a)                       ⇒  2
(char-bits #\c-m-a)                     ⇒  3
constant: char-code-limit

This constant is the strict upper limit on a character’s code value. It is #x110000 unless some future version of Unicode increases the range of code points.

constant: char-bits-limit

This constant is the strict upper limit on a character’s bucky-bits value. It is currently #x10 and unlikely to change in the future.

procedure: bitless-char? object

Returns #t if object is a character with no bucky bits set, otherwise it returns #f .

procedure: char->bitless-char char

Returns char with any bucky bits removed. The result is guaranteed to satisfy bitless-char?.

procedure: char-predicate char

Returns a procedure of one argument that returns #t if its argument is a character char=? to char, otherwise it returns #f.

procedure: char-ci-predicate char

Returns a procedure of one argument that returns #t if its argument is a character char-ci=? to char, otherwise it returns #f.


Next: , Previous: , Up: Characters   [Contents][Index]