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

Daniël Mantione daniel.mantione at freepascal.org
Mon Jun 4 14:15:13 CEST 2007



Op Mon, 4 Jun 2007, schreef gmjimen at burdjia.com:

> 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. 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?

An ansistring uses 8 bit characters, while a widestring uses 
16-bit characters. A widestring is normally UCS-2 or UTF-16 encoded.

Assignments to and from ansistrings convert to and from the system code 
page, i.e. if the system uses an ISO-8859-1 encoding, converting 
ansistrings from/to widestring converts to/from ISO-8859-1.
Further, there is utfencode and utf8decode, which convert an utf-8 
encoded ansistring to/from a widestring.

Daniël


More information about the fpc-pascal mailing list