From: Berend de B. <be...@po...> - 2009-05-19 06:33:09
|
>>>>> "Paul" == Paul Cohen <pa...@se...> writes: Paul> Hi all, I need some advice/feedback on how to convert/create Paul> a UC_STRING from a C pointer to a UTF8 byte sequence (and Paul> vice versa). I can't find any routines or examples in the Paul> Gobo unicode library for doing it. The need for this arises Paul> when writing Eiffel shared libraries (with C-style API:s). Paul> It is unfortunate that I have to create two "string objects" Paul> to perform the "conversion". You can iterate over the C pointer and do what make_from_utf8 does if this is a concern. Paul> Returning a pointer to a UTF8 octet sequence is trickier. It is. I've found out that the only safe way to do this in ISE is to allocate memory with C (malloc), copy the string to there and give a pointer to that area to C. This was tested on a large production system with millions of such calls, and any attempt to give pointers to an Eiffel object would fail with weird errors after a while. There appeared to be no safe way to retrieve a pointer to an ISE Eiffel object, whatever tricks were applied. -- Cheers, Berend de Boer |