Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2005-06

Shortstrings/ ANSIStrings

2 messages · 1 person · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

What is the main difference between the shortstrings (256 byte) and the ANSI Strings? 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...

Reply by email

Unknown author
to Unknown author
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.

Reply by email