[fpc-pascal]Ansistrings

Pierre Muller pierre at freepascal.org
Fri Jun 21 11:50:05 CEST 2002


At 11:40 21/06/2002 , Jonas Maebe a écrit:


>On Fri, 21 Jun 2002, Florian Klaempfl wrote:
>
> > >>Well really when I need to null terminate the ansistring with:
> > >>ansist:=ansist+#0;
> > >
> > >Ansistrings are always null-terminated.
> >
> > Are you sure :) ?
>
>Yes. There is no helper to convert an ansistring to a pchar (it's just a
>pointer to an ansirec that gets its type changed to a pointer to a char)
>and all ansistring handling routines in the RTL make sure all ansistrings
>are/remain null-terminated.
This is true, but don't forget that in constrast to 
pchar, ansistrings can contains #0 in the middle of a string...
Thus printing an ansistring drectly or by
typecasting int into a pchar might
result in different outputs.





More information about the fpc-pascal mailing list