From: James B. <ja...@ja...> - 2006-04-27 20:28:32
|
Juho Snellman <js...@ik...> writes: > * I'm not sure that the interface is quite right. It seems probable > that at one point or another somebody will need to use multiple > external formats at once (ebcdic for pathnames and latin-1 for a > database connection, or something). So we might need to be able to > parametrize the external format to be used when defining the > types. As a silly example: > > (define-alien-routine strdup (c-string :external-format :latin-1) > (str (c-string :external-format :utf-8))) I agree; this is what the half-finished patch I have adding support for string encodings to CFFI looks like as well: (defcfun "strdup" (:string :encoding :latin-1) (str (:string :encoding :utf-8))) > James, Luis, would something like this be useful for CFFI? Would > the proposed interface work for you? Any opinions on the c-string > issue mentioned above? CFFI wants to operate at a lower level than this. The sort of interface that would be really useful for us would be versions of STRING-TO-OCTETS and OCTETS-TO-STRING that operate on SAPs instead of octet vectors. IIRC, there are unexported functions in SBCL for doing this for the various encodings, but nothing exported. James |