Useful Utilities

This page gives information about useful utilities included in CL-HTTP, for performing translations and other operations frequently needed when programming web sites.

Escaping and unescaping strings for URLs


string-escape-special-chars (string &optional start end)

Escapes characters illegal in URLs using %xx notation. For example:

(string-escape-special-chars "Contact")

 The second value returned indicates if any characters were escaped.

write-string-escaping-special-chars (string &optional stream start end))

As string-escape-special-chars, but writes the escaped string to a stream.

string-unescape-special-chars (string &optional start end)

Unescapes characters encoded with percent encoding. For example:

(string-unescape-special-chars "")

The second value returned indicates if any characters were unescaped, and the third value indicates if a new string was returned.

Escaping and unescaping strings for HTML

write-string-quoting-specials (string &optional stream start end)

Writes a string to the stream, encoding the four special characters disallowed in HTML:


For example:

(write-string-quoting-specials "Write <p>&nbsp;</p>" *standard-output*)
Write &lt;p&gt;&amp;nbsp;&lt;/p&gt;

Encoding and decoding LISP forms

write-to-armor-plated-string (form)

Encodes a LISP form as a base64-encoded string that can be included in a URL or as the value of a form field. For example:

(write-to-armor-plated-string '(ant bee cat dog))

read-from-armor-plated-string (string)

Encodes a base64-encoded string back into a LISP form. For example:

(read-from-armor-plated-string "KEFOVCBCRUUgQ0FUIERPRyk*")

blog comments powered by Disqus