[fpc-pascal] Shortstrings/ ANSIStrings

Michael.VanCanneyt at Wisa.be Michael.VanCanneyt at Wisa.be
Fri Sep 2 16:00:03 CEST 2005



On Tue, 14 Jun 2005 antal at carmelcomputer.com wrote:

> What is the main difference between the shortstrings (256 byte) and the ANSI Strings?

Shortstrings are on the stack, and have the length stored in the 0-th byte.
AnsiStrings are on the heap, and have their length stored somewhere hidden.
Ansistrings are more like the C PChar when it comes to memory layout.

This means that
  MyString[0]:=char(13)
will not work for an ansistring.

> I mean, upon using the Strings, we have plenty of functions, manipulating the string,
> while with ANSIStrings we have certain difficulties obtaining the same result
> This is ranging from Pos(), Delete(), String addition, and so on...

All standard FPC functions work with AnsiStrings and ShortStrings.

Can you give an example of code or a function that does not work ?

Michael.



More information about the fpc-pascal mailing list