The Photoshop file format documentation mentions Pascal strings without explaining what they are.
So, what are they, and how are they encoded?
Advertisements. The string in Pascal is actually a sequence of characters with an optional size specification. The characters could be numeric, letters, blank, special characters or a combination of all. Extended Pascal provides numerous types of string objects depending upon the system and implementation.
The string in Pascal is actually a sequence of characters with an optional size specification. The characters could be numeric, letters, blank, special characters or a combination of all.
Pascal - Strings. AnsiStrings − Ansistrings are strings that have no length limit. Pascal provides only one string operator, string concatenation operator (+).
GCC and clang (and possibly others) accept the -fpascal-strings option which allows you to declare pascal-style string literals by having the first thing that appears in the string be a \p, e.g. "\pfoo". Not exactly portable, but certainly nicer than funky macros or the runtime construction of them.
Character and string types. Free Pascal supports several character and string types. They range from single ANSI characters to unicode strings and also include pointer types. Differences also apply to encodings and reference counting.
A Pascal-style string has one leading byte (length
), followed by length
bytes of character data.
This means that Pascal-style strings can only encode strings of between 0 and 255 characters in length (assuming single-byte character encodings such as ASCII).
As an aside, another popular string encoding is C-style strings which have no length specifier, but use a zero-byte to denote the end of the string. They therefore have no length limit.
Yet other encodings may use a greater number of prefix bytes to facilitate longer strings. Terminator bytes/sentinels may also be used along with length prefixes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With