How to implement Lispworks' CONVERT-FROM-FOREIGN-STRING :null-terminated-p?
> play safe: append max_bytes_per_char (8) NULL bytes, give the
> count as the length of the original LISP string +1.
+1 is not correct for UTF-16, UCS-2, UNICODE-32 etc.
I can add 4-8-1000 zeros, but the LispWorks API also requires telling the byte-count to the programmer. And there, +1 is not correct (unexpected odd bytecount for UTF-16/32(!), not +4, nor +2, nor +8).
I don't believe
(with-foreign-string (foreign elem-size bytecount
(declare (ignore foreign))
should return 1001, nor 9, nor 5. Just 2.
But UCS-2 -> 4, not 3, not 1002
and UNICODE-32 -> 8
> this cannot be done properly for iconv-based encodings since there is
> no way to query libiconv for this information.
> I think these are set correctly for built-in encodings.
I believe this too, that's why I reported this as libiconv bug.
lispbibl.d has the slots and doesn't document that they may not be valid.
What's left is
o have iconv report on information
o have CLISP use iconvo information
o declare failure to implement LispWorks with-foreign-string API: no null-terminated-p, always (hidden) trailing N zeroes.
o declare total failure to implement the converse function convert-from-foreign-string :null-terminated-p. That means, UTF-16 etc. strings are not usable with CLISP. E.g. No easy access to any of Microsoft's (and other) FooBarW() functions.