A library for implementation-independent, portable US-ASCII encoding and decoding.
US-ASCII character constants:
+NUL+
+#\A+
+#\0+
etc.
Functions mapping Lisp characters to and from US-ASCII:
ascii-code-char
ascii-char-code
Functions mapping Lisp strings to and from sequences of US-ASCII:
ascii-code-string
ascii-string-code
A macro to ease US-ASCII encoding of Lisp character literals:
ascii
Trivial US-ASCII is available on Ultralisp and is easy to install using Quicklisp.
Add the Ultralisp repository:
CL-USER> (ql-dist:install-dist "http://dist.ultralisp.org/")
Install Trivial US-ASCII:
CL-USER> (ql:quickload :trivial-us-ascii)
Load the trivial-us-ascii
package:
CL-USER> (require :trivial-us-ascii)
NIL
CL-USER> (use-package :trivial-us-ascii)
T
Constants:
CL-USER> +NUL+
0
CL-USER> +#\A+
65
Character mapping:
CL-USER> (ascii-code-char 0)
#\Nul
CL-USER> (ascii-code-char 65)
#\A
CL-USER> (ascii-char-code #\Nul)
0
CL-USER> (ascii-char-code #\A)
65
String mapping:
CL-USER> (ascii-string-code '(simple-array (unsigned-byte 8) (*)) "Hello, world!")
#(72 101 108 108 111 44 32 119 111 114 108 100 33)
CL-USER> (ascii-code-string #(72 101 108 108 111 44 32 119 111 114 108 100 33))
"Hello, world!"
Inlining:
CL-USER> (macroexpand-1 '(ascii #\Space))
32
T
Patches are welcome.
Trivial US-ASCII is in the public domain, or licensed permissively in jurisdictions hostile to the public domain.
See LICENSE.