bohonghuang / cl-gtk4

GTK4/Libadwaita/WebKit2 bindings for Common Lisp.
GNU Lesser General Public License v3.0
215 stars 9 forks source link

Setting text doesn't work with unicode strings #22

Closed rationalis-petra closed 1 year ago

rationalis-petra commented 1 year ago

I've noticed several functions that set/provide/insert text - for example (setf text-buffer-text) will, in the GTK version accept a length (bytes) parameter, but the wrappers will populate this parameter with length called on the argument. (i.e. number of characters, not number of bytes). In the case where the text contains any unicode characters, this can cause bugs, as the length provided by CL is wrong.

bohonghuang commented 1 year ago

Thank you for the report. The strings passed through CFFI are terminated with \0, so I changed the length in the parameters to -1. Now, (setf (gtk:text-buffer-text ...) ...) and (setf (gtk:entry-buffer-text ...) ...) should be able to use UTF-8 strings.