[fpc-pascal] use cwstring or fpwidestring on linux

Sven Barth pascaldragon at googlemail.com
Fri Oct 4 23:02:23 CEST 2013

On 04.10.2013 22:14, stdreamer wrote:
> On 04/10/2013 10:44 μμ, Sven Barth wrote:
>> On 04.10.2013 21:15, stdreamer wrote:
>>> On 04/10/2013 9:08 μμ, Sven Barth wrote:
>>>> The main difference is that cwstring uses the Widestring manager of the
>>>> system's C library while fpwidestring is a full Pascal Widestring
>>>> manager.
>>> So by using cwstring instead of fpwidestring am I safe to assume that
>>> the widestrings used and returned by DLLs/SOs will work correctly even
>>> when they are used as results in functions (taking in to account that
>>> widestrings are not ref counted in the first place of course)?
>> No. That one has nothing to do with any Widestring manager, but with the
>> memory manager. The purpose of the widestring manager is to convert from
>> strings of one encoding to another encoding.
>> Please note that on Windows WideStrings will work across DLL boundaries,
>> because they are managed by Windows. This is not the case on other
>> targets though as there WideString = UnicodeString and UnicodeStrings
>> have the same restrictions as AnsiString.
>> Regards,
>> Sven
> Oh well I was kind of hopping that a cwstrings will have its own memory
> manager as well but it was to good to be true in the first place thanks
> for the input.

If you want to share Unicode- or AnsiStrings between library and 
application you need to use a common memory manager. For example you 
could use unit "cmem" as one of the first units of both programs. It 
will work on Unix based systems and *should* work on Windows ones as well.


More information about the fpc-pascal mailing list