Thanks for the answers.
I think I'll duplicate the functions, one for ASCII (ANSISTRING) coding and the other for UTF-8 (WIDESTRING). I think this is the best way.
But I've look for the description for UTF8Encode, UTF8Decode, UTF8ToAnsi and UTF8ToUnicode in the documentation and I can't find it. What does they do?
Guillermo Martínez Jiménez
[p.s.] Por cierto, escribo tonterías y hago budujos que podéis ver y leer aquí --> http://dibujantemomar.deviantart.com/ y aquí --> http://dibujantemomar.spaces.live.com/
Show quoted text 75 lines
------------------------------
Message: 6
Date: Mon, 4 Jun 2007 14:11:22 +0200 (CEST)
From: (Marco van de Voort)
Subject: Re: [fpc-pascal] Using AnsiString/WideString with C Library
To: FPC-Pascal users discussions
Message-ID:
Content-Type: text/plain; charset="US-ASCII"
> 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)
------------------------------
Message: 7
Date: Mon, 4 Jun 2007 14:15:13 +0200 (CEST)
From: Dani?l Mantione
Subject: Re: [fpc-pascal] Using AnsiString/WideString with C Library
To: FPC-Pascal users discussions
Message-ID:
Content-Type: text/plain; charset="iso-8859-1"
Op Mon, 4 Jun 2007, schreef
> I've read the documentation and I find that I can use WIDESTRING in a sim=
ilar
> 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=EBl
------------------------------