retroforth/doc/book/techniques/characters
crc 6a4aaf8eac prefix: namespace is now sigil:, rename words, update examples, update docs
FossilOrigin-Name: 25cf19660ab7728d7bfee2722ea826a8a438faf92b2504b28d922d2958906aed
2021-03-30 11:58:25 +00:00

65 lines
1.2 KiB
Text

# Working With Characters
RETRO provides words for working with ASCII characters.
## Sigil
Character constants are returned using the `$` sigil.
## 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.