[fpc-pascal] How to know the string type of a variable?

Michael Van Canneyt michael at freepascal.org
Mon Dec 30 23:40:52 CET 2013



On Tue, 31 Dec 2013, Juha Manninen wrote:

> On Mon, Dec 30, 2013 at 9:17 PM, Mattias Gaertner
> <nc-gaertnma at netcologne.de> wrote:
>> if FindInvalidUTF8Character(PChar(Pointer(s)),length(s))<0 then
>>   // UTF-8
>
> Uhhh! I will be totally screwed when I must do a unicode conversion myself.
> What was this "PChar(Pointer(s))" again? PChar is a pointer, why does
> it need a double cast?

Pchar(Ansistring) has some special compiler treatment.

If you omit the double cast, pchar(S) will point to a #0 character for an empty string.
If you include the double cast, PChar(Pointer(s)) is Nil for an empty string.

Michael.



More information about the fpc-pascal mailing list