Scieneer Common Lisp 1.3.9 online documentation

Characters

Introduction

The Scieneer Common Lisp character set is 16-bit Unicode (UCS-2). Conversion of ISO-8859-1 and UTF-8 external formats is handled internally, and the C library iconv function is called to handle other external formats.

For simple character format conversion between a lisp string and a lisp byte vector, see ext:make-string-from-bytes, and ext:make-bytes-from-string.

ext:make-string-from-bytes bytes from &optional start end[Function]

Convert the foreign character bytes in format from into a newly created native string.

ext:bytes-string-length bytes from &optional start end[Function]

Return the length in native characters of the foreign bytes when converted from the foreign character format from.

ext:make-bytes-from-string string to &optional start end[Function]

Convert the string to the foreign format to, returning the result in a newly created byte vector.

ext:string-byte-length string to &optional start end[Function]

Return the length in bytes of the string when converted to the foreign character format to.

ext:*default-external-format*[Variable]

The default character format used when opening characters streams. The global value is initialized at startup using: the command line argument "-locale", or the environment variable SCL_LOCALE, or the system locale which is typically derived from the environment variables LC_CTYPE etc.

lisp::*native-encoding*[Global Variable]

The lisp internal string character encoding.


Iconv interface

ext:iconv-desc[Class]

Class precedence list:

ext:iconv-desc, structure-object, ext:instance, t.

Character conversion descriptor.

ext:make-iconv-desc to from &optional error-value[Function]

Make a character format conversion descriptor for conversion from the format from to the format to, for use of the foreign iconv library routine.

ext:close-iconv-desc iconv-desc[Function]

Close the given iconv-desc character format conversion descriptor, deallocating associated resources.

ext:iconv-from-natural iconv-desc input-sap start available buffer-sap head requested[Function]

Convert the native lisp format characters stored in foreign storage pointed to by input-sap, from offset start and using at most the available characters, into a foreign character encoding stored in foreign storage pointed to by buffer-sap at the offset head and for up to the requested number of bytes. The character conversion is determined by the iconv-desc. The number of characters consumed and the number of bytes written are returned. The conversion stops at the first conversion error, and the error will be signaled if it occurs at the first character otherwise a partial conversion is returned.

ext:iconv-to-natural iconv-desc buffer-sap head available output-sap start requested[Function]

Convert the foreign characters stored in foreign storage pointed to by buffer-sap, starting at offset head and using at most the available bytes, directly into a foreign string in the native lisp character format stored in foreign storage pointed to by output-sap at offset start and for up to the requested number of characters. The character conversion is determined by the iconv-desc. The number of bytes consumed and the number of characters written are returned. The conversion stops at the first conversion error, and the error will be signaled if it occurs at the first byte otherwise a partial conversion is returned.

ext:convert-string-to-system-area iconv-desc string start available buffer-sap head requested[Function]

Convert the native string, from offset start and using at most the available characters, into a foreign character encoding stored in foreign storage pointed to by buffer-sap at the offset head and for up to the requested number of bytes. The character conversion is determined by the iconv-desc. The number of characters consumed and the number of bytes written are returned.

ext:convert-system-area-to-string iconv-desc buffer-sap head available string start requested[Function]

Convert the foreign characters stored in foreign storage pointed to by buffer-sap, starting at offset head and using at most the available bytes, directly into a native string at offset start and for up to the requested number of characters. The character conversion is determined by the iconv-desc. The number of bytes consumed and the number of characters written are returned.

ext:convert-string-to-bytes iconv-desc string start available bytes head requested[Function]

Convert the native string, from offset start and using at most the available characters, into a foreign character encoding storing the result directly into the bytes vector string at the offset head and for up to the requested number of bytes. The character conversion is determined by the iconv-desc. The number of characters consumed and the number of bytes written are returned.

ext:convert-bytes-to-string iconv-desc bytes head available string start requested[Function]

Convert the foreign character bytes, starting at offset head and using at most the available bytes, directly into a native string at offset start and for up to the requested number of characters. The character conversion is determined by the iconv-desc. The number of bytes consumed and the number of characters written to the string are returned. The conversion stops at the first conversion error, and the error will be signaled if it occurs at the first byte otherwise a partial conversion is returned.


Alien c-call:c-string

When an alien function is defined with a c-call:c-string argument, a lisp string passed to the function with be converted to the c-call:*foreign-encoding*. The storage for the string is allocated on the stack when possible, so the extent ends upon return from the alien function.

The macro c-call:with-deported-string provides an alternative for locally deporting a string, allocating bytes on the stack.

When an alien function is defined to return a c-call:c-string, the return value is naturalised creating a lisp string.

c-call:*foreign-encoding*[Variable]

The default character format encoding to use when converting to or from an alien c-call:c-string. The default encoding is :iso-8859-1.

c-call:with-deported-string (bytes string &optional format start end) &body body[Macro]

Convert a simple-string string into bytes in the optional format for the extent of the body. Where possible the bytes are allocated on the stack.