[cffi-devel] a thought on string encodings

Hoehle, Joerg-Cyril Joerg-Cyril.Hoehle at t-systems.com
Thu Dec 22 17:50:46 UTC 2005


Hi,

I hope encoding stuff will be the next great addition to CFFI. Here's some vague idea I once had.
I got the impression that there are (at least) two types of functions:
 - one where the conversion depends on whatever dynamic calling context
 - another where the conversion is fixed, i.e. depends on the function only, not on the caller (but possibly on the library).

Given CFFI's post transformers, I suspect that there's an opportunity to model both kinds of functions, i.e.
 - some where defcfun expands to defaults of custom:*foreign-encoding* (in CLISP speak)
 - some where the wrappers within defcfun impose a given encoding, e.g. ASCII, ISO-8859-1, UTF-8 or UTF16.

Examples that come to mind are the GDI YouNameIt*W() functions on MS-Windows, where the strings are all UTF-16. One could use that alternatively with getenv(), which might ask for UTF-8 (or just use the default from the Lisp system).

Sometimes it seems, the encoding depends on the library to which the function belongs.

Just my $0.02, and I'm eager to see what kind of design you'll come up with.

Regards,
	Jörg Höhle.



More information about the cffi-devel mailing list