[cells-gtk-devel] UTF-8 support
Peter Hildebrandt
peter.hildebrandt at gmail.com
Thu Jan 17 13:39:42 UTC 2008
Changing lisp-string-to-foreign in cffi/src/strings.lisp like this fixes
the problem (at least for sbcl):
(defun lisp-string-to-foreign (string ptr size)
"Copy at most SIZE-1 characters from a Lisp STRING to PTR.
The foreign string will be null-terminated."
(decf size)
(loop with i = 0 for char across #-sbcl string #+sbcl
(sb-ext:string-to-octets string :external-format :utf-8)
while (< i #-sbcl size #+sbcl (length (sb-ext:string-to-octets
string :external-format :utf-8)))
do (%mem-set #-sbcl (char-code char)
#+sbcl char
ptr :unsigned-char (post-incf i))
finally (%mem-set 0 ptr :unsigned-char i)))
I will look at the newer cffi and see how that plays out.
Dmitri Hrapof wrote:
> Peter Hildebrandt wrote:
>> Dmitri Hrapof wrote:
>>> Yes, now it's clear.
>>> MK-BUTTON expects a Lisp string, being decent Lisp function, not some
>>> FFI abomination ;)
>>> So the solution is to place (sb-ext:string-to-octets "foo äöüß bar"
>>> :external-format :utf-8) deeper, between MK-BUTTON and
>>> GTK-BUTTON-SET-LABEL.
>> Nope. I think the problem is somewhere in cffi (maybe we're using
>> different versions?). I'm doing:
> Stupid me! Just reread my answer and saw the error, but wasn't fast
> enough to correct myself befor you did :)
> You are right, the difference is in CFFI, in FOREIGN-STRING-ALLOC
> Use CFFI 0.9.2 instead of CFFI included in cells-gtk tarball.
> Also note that darcs version of CFFI is a new version, and is not very
> compatible with 0.9.2
> It may or it may not work with cells-gtk.
>
> Sincerely yours,
> Dmitri
More information about the cells-gtk-devel
mailing list