From: Yaroslav K. <kav...@je...> - 2005-07-12 10:36:38
|
Pascal Bourguignon wrote: >>>>Function "iconv" was necessary. >>>>First has written so: >>>> >>>>(DEFUN ICONV (s from to) >>>> (EXT:CONVERT-STRING-FROM-BYTES >>>> (EXT:CONVERT-STRING-TO-BYTES s to) from)) >>> >>> >>>if you need this, you are doing something wrong. >>>if you have a string which has been incorrectly encoded, you need to >>>modify the stream format or something - look at the source of the >>>string. >> >>Tcl library (through FFI) get and put strings in UTF-8. I should > > convert > >>my strings to UTF-8 and convert the received result from UTF-8. Or I >>should write all sourcs in UTF-8 and run clisp with "-E UTF-8"? > > > Here is your error! It sends you UTF-8 bytes and you put them into a > string! > You shoud instead decode them as a UTF-8 byte vector! > > > The easiest way is to set *FOREIGN-ENCODING* to charset:utf-8 > > (setf custom:*FOREIGN-ENCODING* charset:utf-8) > > so the FFI does it for you automatically. > > > Otherwise, if some functions returned utf-8 but some others returned > other encodings, you'd have to substitute (ffi:array ffi:uint8) for > ffi:string and use ext:convert-string-from-bytes with the > corresponding encoding around each ffi call. > Oops! Sorry and many thanks! I have not noticed the elephant... :( It is necessary save the current custom:*FOREIGN-ENCODING* and restore after use? -- WBR, Yaroslav Kavenchuk. |