On Wed, 26 Sep 2007 16:29:20 +0200 (CEST) [EMAIL PROTECTED] (Marco van de Voort) wrote:
> > Am Mittwoch, den 26.09.2007, 13:24 +0200 schrieb Marco van de Voort: > > > > > > > > > > Ansistrings (and thus {$longstrings on}) work fine. > > > > > > > > Ah, okay. The Fog is lifting fastly. :) > > > > > > > > And AnsiStrings are pretty much compatible to C's char*. Very > > > > handy. > > > > > > Yes, though ansistrings may contain #0's. > > > > Interesting, how will a cast handle this case? > > > Will it change the intermediate #0 to something else or will the > > resulting pchars be cut at first occurrence? > > A cast is really a cast. IOW the cast pchar(ansistring) is mostly a > no-op. Traditional C code then usually treats the #0 as end of > string. PChar(AnsiString) was a no-op typecast in the past and is nowadays a function. It checks whether the AnsiString is nil and if yes returns a pointer to a string containing one character: #0. That means: Pointer(AnsiString) <> Pointer(PChar(AnsiString)) To get a no-op typecase you can use: MyPChar:=PChar(Pointer(AnsiString)); > It's mostly important when ansisstring is abused as general purpose > buffer, but generally it is better to use dyn arrays for that. Mattias _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal