What is a Pascal-style string?

The Photoshop file format documentation mentions Pascal strings without explaining what they are.

So what is it and how are they encoded?

+7
string encoding pascal
source share
1 answer

A Pascal-style string contains one high byte ( length ), followed by length bytes of character data.

This means that Pascal-style strings can only encode strings between 0 and 255 characters long (assuming single-byte character encodings such as ASCII).

Alternatively, another popular string encoding is C-style strings that do not have a length specifier but use null bytes to indicate the end of a string. Therefore, they do not have a length limit.

However, other encodings may use more prefix bytes to facilitate longer strings. Terminator bytes / hourly can also be used with length prefixes.

+6
source share

All Articles