[fpc-pascal] Using AnsiString/WideString with C Library

Marco van de Voort marcov at stack.nl
Mon Jun 4 14:11:22 CEST 2007


> This way I can use Pascal strings with C functions.
> 
> I've read the documentation and I find that I can use WIDESTRING in a similar
> way, but I'm not sure which character codification WIDESTRING uses

UCS2 which is a subset (more like a draft for) of UTF16.  Maybe Microsoft
has fixed this to be fully UTF16 compliant in XP+ though.

> The C library uses 'standard C strings' (that is 'char *string;') an
> there's a function to define the character codification to be used by the
> library. It's possible to use ASCII, UTF-8, UTF-16 and UTF-32.

> Can WIDESTRING use all UNICODE codifications and ASCII strings?

If there are differences, they revolve around the differences between UCS2
and UTF16. (surrogate pairs mostly, maybe endianess support)
 
> If it can't, is there a way to use UNICODE strings?

There is no such thing. There are multiple unicode encodings (UTF-*, UCS-*
etc)



More information about the fpc-pascal mailing list