Macro
fli
with-foreign-string (pointer element-count byte-count &key external-format null-terminated-p) string &body body => last
body::= form*
A symbol bound to a pointer to the foreign string.
A symbol bound to the number of elements in the foreign string.
A symbol bound to the number of bytes occupied by the foreign string. If the element size of the string is equal to one byte, then byte-count will be the same as element-count.
A keyword specifying the format to be used for the foreign string.
Ift
, the foreign string is terminated by a null character. The null character is included in the element-count of the string.
The Lisp string to convert.
A list of forms to be executed.
A form to be executed.
The value of the last form in body.
with-foreign-string
is used to dynamically convert a Lisp string to a foreign string and execute a list of forms using the foreign string. The macro first converts string, a Lisp string, into a foreign string. The symbol pointer is bound to a pointer to the start of the string, the symbol element-count is set equal to the number of elements in the string, and the symbol byte-count is set equal to the number of bytes the string occupies. Then the list of forms specified by body is executed. Finally, the memory allocated for the foreign string and pointer is de-allocated. char*
. For Unicode encoded strings, specify:unicode
. If you want to pass a string to the Win32 API, known asSTR
in the Win32 API terminology, specify *multibyte-code-page-ef*
, which is a variable holding the external format corresponding to the current Windows multi-byte code page. t
. If the string terminates in a null character, it is included in the element-count. fli:with-foreign-string
. convert-to-dynamic-foreign-string
with-dynamic-foreign-objects