Hello Michael, Sorry for the late reply.
On Fri, Mar 19, 2010 at 8:05 AM, Michael Raskin <f9cef...@yandex.ru> wrote: > I use callback feature of CFFI. I want to use an encoding as a default > and if I get an invalid string (non-UTF-8 in my case), I'd just reject > it by returning an error. Unfortunately, if I declare string arguments > with encoding, attempts by CFFI to decode the string raise an error > which prevents me from returning protocol-compliant error to the caller. [...] > This can be mitigated by patching CFFI. If I just wrap the conversion > in ignore-errors, I lose the distinction between an invalid string and > null pointer, but I get a chance to process the request (both cases are > wrong in my case). [...] > Would you please consider adding some similar modification in official > CFFI repository? One way to handle this issue is the following: (let ((babel-encodings:*suppress-character-coding-errors* t)) (foreign-string-alloc "pão" :encoding :ascii)) But I'm not sure whether this is applicable in your case. The proper solution to this issue is to add some sort of :ignore-errors parameter to foreign-string-alloc and to the :string type. I've registered this wishlist item in <http://bugs.launchpad.net/cffi/+bug/622421>. Cheers, -- Luís Oliveira http://r42.eu/~luis/ _______________________________________________ cffi-devel mailing list cffi-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel