What is a Pascal-style string?

前端 未结 1 424
独厮守ぢ
独厮守ぢ 2020-12-19 01:25

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

So, what are they, and how are they encoded?

相关标签:
1条回答
  • 2020-12-19 02:29

    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.

    0 讨论(0)
提交回复
热议问题