[fpc-pascal] Empty string
flavio.etrusco at gmail.com
Fri Mar 7 04:50:23 CET 2008
To the OP: are you using the AnsiString as a buffer (that contains
"several" strings)? Otherwise, using "MyString <> '' " would do
because #0 is only valid as terminator in UTF-8 too.
BTW, IIRC Delphi would generate faster code for the above construction
instead of "Length(MyString) <> 0" because of locking.
> > I thought string should be accessed from 1 not 0 for compatibility.
> > And it is what I am doing.
> > for i := 1 to length(s) do ...
> > so I am not sure that using s is safe
s won't compile. Not in Delphi, at least.
> If memory serves, the  element was originally used to hold a byte that
> was equivalent to the string length. This was in the Turbo Pascal days
> though. I don't recall if that behavior was carried over into Delphi or
> the Delphi mode of FPC.
That's correct, but for ShortStrings only.
More information about the fpc-pascal