2019-03-18 17:20:42 +01:00
|
|
|
# Working With Characters
|
|
|
|
|
|
|
|
RETRO provides words for working with ASCII characters.
|
|
|
|
|
2021-03-30 13:58:25 +02:00
|
|
|
## Sigil
|
2019-03-18 17:20:42 +01:00
|
|
|
|
2021-03-30 13:58:25 +02:00
|
|
|
Character constants are returned using the `$` sigil.
|
2019-03-19 16:12:16 +01:00
|
|
|
|
|
|
|
## Namespace
|
|
|
|
|
|
|
|
Words operating on characters are in the `c:` namespace.
|
|
|
|
|
|
|
|
## Classification
|
|
|
|
|
|
|
|
RETRO provides a number of words to determine if a character
|
|
|
|
fits into predefined groups.
|
|
|
|
|
|
|
|
The primary words for this are:
|
|
|
|
|
|
|
|
* `c:consonant?`
|
|
|
|
* `c:digit?`
|
|
|
|
* `c:letter?`
|
|
|
|
* `c:lowercase?`
|
|
|
|
* `c:uppercase?`
|
|
|
|
* `c:visible?`
|
|
|
|
* `c:vowel?`
|
|
|
|
* `c:whitespace?`
|
|
|
|
|
|
|
|
There are also corresponding "not" forms:
|
|
|
|
|
|
|
|
* `c:-consonant?`
|
|
|
|
* `c:-digit?`
|
|
|
|
* `c:-lowercase?`
|
|
|
|
* `c:-uppercase?`
|
|
|
|
* `c:-visible?`
|
|
|
|
* `c:-vowel?`
|
|
|
|
* `c:-whitespace?`
|
|
|
|
|
|
|
|
All of these take a character and return either a `TRUE` or
|
|
|
|
`FALSE` flag.
|
|
|
|
|
|
|
|
## Conversions
|
|
|
|
|
|
|
|
A few words are provided to convert case. Each takes a character
|
|
|
|
and returns the modified character.
|
|
|
|
|
|
|
|
* `c:to-lower`
|
|
|
|
* `c:to-number`
|
|
|
|
* `c:to-upper`
|
|
|
|
* `c:toggle-case`
|
|
|
|
|
|
|
|
RETRO also has `c:to-string`, which takes a character and
|
|
|
|
creates a new temporary string with the character.
|
|
|
|
|
|
|
|
## I/O
|
|
|
|
|
|
|
|
Characters can be displayed using `c:put`.
|
|
|
|
|
|
|
|
```
|
|
|
|
$a c:put
|
|
|
|
```
|
|
|
|
|
|
|
|
With the default system on BSD, Linux, and macOS (and other
|
|
|
|
Unix style hosts), `c:get` is provided to read input. This
|
|
|
|
may be buffered, depending on the host.
|