I created a simple patch for gtk-ffi.lisp that adds a call to sb-ext:string-to-octets to all gtk functions that take strings. This way all gtk functions transparently accept utf-8 characters.

Here's the patch
http://www.washbear-network.de/peterblog/wp-content/uploads/2008/01/gtk-ffi-utf8-sbcl.patch

Ingo, let me know whether that solves your problem.

Or a version that works against my multithreaded [1] version
http://www.washbear-network.de/peterblog/wp-content/uploads/2008/01/gtk-ffi-utf8-sbcl-threading.patch

The patch requires the latest cffi, that is 0.9.2. Cells-gtk works fine with this.

I have not looked at the other direction yet, that is, what happens if the user enters utf-8 characters somewhere.

Any questions, let me know.

Peter
-----
[1] http://www.washbear-network.de/peterblog

Peter Hildebrandt wrote:

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


_______________________________________________
cells-gtk-devel site list
[email protected]
http://common-lisp.net/mailman/listinfo/cells-gtk-devel

Reply via email to