All Manuals > Foreign Language Interface User Guide and Reference Manual > 7 Function, Macro and Variable Reference

convert-to-dynamic-foreign-string Function

Summary

Converts a Lisp string to a foreign string within the scope of the body of a with-dynamic-foreign-objects macro.

Package

fli

Signature

convert-to-dynamic-foreign-string string &key external-format null-terminated-p allow-null => pointer, length, byte-count

Arguments
string
A Lisp string.
external-format
An external format specification.
null-terminated-p
If t, the foreign string terminates with a null character. The default value is t.
allow-null
A boolean. The default is nil.
Values
pointer
A FLI pointer to the foreign string.
length
The length of the string (including the terminating null character if there is one).
byte-count
The number of bytes in the converted string.
Description

The function convert-to-dynamic-foreign-string converts a Lisp string to a foreign string, and returns a pointer to the string and the length of the string. The memory allocation for the string and pointer is within the scope of the body of a with-dynamic-foreign-objects command.

external-format is interpreted as by with-foreign-string. The names of available external formats are listed in section 26.6 External Formats to translate Lisp characters from/to external encodings in the LispWorks® User Guide and Reference Manual.

null-terminated-p specifies whether the foreign string is terminated with a null character. It defaults to t.

If allow-null is non-nil and string is nil then a null pointer pointer is returned. Otherwise, an error is signalled if string is nil.

See also

allocate-dynamic-foreign-object
convert-from-foreign-string
convert-to-foreign-string
set-locale
set-locale-encodings
with-dynamic-foreign-objects
with-foreign-string
26.6 External Formats to translate Lisp characters from/to external encodings in the LispWorks® User Guide and Reference Manual
5.2.5 Calling a C function that takes an array of strings


Foreign Language Interface User Guide and Reference Manual - 01 Dec 2021 19:34:58