Next: , Previous: , Up: asciis   [Index]


1.10.2 Conversion utilities

The following bindings are exported by the library (vicare language-extensions ascii-chars). The identifiers whose name is prefixed with ‘$’ are bound to unsafe operations: they do not validate the arguments and applying them to invalid arguments leads to undefined behaviour.

Function: ascii-dec->fixnum fx
Syntax: $ascii-dec->fixnum fx

Given a fixnum representing a decimal digit in ASCII encoding: return the corresponding fixnum in the range [0, 9].

(ascii-dec->fixnum (char->integer #\5))
⇒ 5
Function: fixnum->ascii-dec fx
Syntax: $fixnum->ascii-dec fx

Given a fixnum in the range [0, 9]: return the corresponding fixnum representing the decimal digit in ASCII encoding.

(fixnum->ascii-dec 5)
⇒ (char->integer #\5)
Function: ascii-hex->fixnum fx
Syntax: $ascii-hex->fixnum fx

Given a fixnum representing a hexadecimal digit in ASCII encoding: return the corresponding fixnum in the range [0, 15].

(ascii-hex->fixnum (char->integer #\5))
⇒ 5

(ascii-hex->fixnum (char->integer #\A))
⇒ 10
Function: fixnum->ascii-hex fx
Syntax: $fixnum->ascii-hex fx

Given a fixnum in the range [0, 15]: return the corresponding fixnum representing the hexadecimal digit in ASCII encoding.

(fixnum->ascii-hex 5)
⇒ (char->integer #\5)

(fixnum->ascii-hex 10)
⇒ (char->integer #\A)