Next: , Up: Strings in GPC

3.4.1 What's this confusion about strings?

Turbo Pascal strings have a length byte in front. Since a byte has the range 0 .. 255, this limits a string to 255 characters. However, the Pascal string schema, as defined in section of the ISO 10206 Extended Pascal standard, is a schema record:

       String (Capacity: Integer) = record
         Length: 0 .. Capacity;
         String: packed array [1 .. Capacity + 1] of Char

The + 1 is a GPC extension to make it feasible to automatically add the #0 terminator when passing or assigning them to CStrings. Thus at the expense of a little added complexity (must declare capacity, don't use GetMem without explicit initialization of the Capacity field, and the additional space requirement) you can now have very long strings.