@@ -94,13 +94,17 @@ \section{\module{struct} ---
9494number of bytes. As a special case, \code {'0s'} means a single, empty
9595string (while \code {'0c'} means 0 characters).
9696
97- The \character {p} format character can be used to encode a Pascal
98- string. The first byte is the length of the stored string, with the
99- bytes of the string following. If count is given, it is used as the
100- total number of bytes used, including the length byte. If the string
101- passed in to \function {pack()} is too long, the stored representation
102- is truncated. If the string is too short, padding is used to ensure
103- that exactly enough bytes are used to satisfy the count.
97+ The \character {p} format character encodes a "Pascal string" , meaning
98+ a short variable-length string stored in a fixed number of bytes.
99+ The count is the total number of bytes stored. The first byte stored is
100+ the length of the string, or 255, whichever is smaller. The bytes
101+ of the string follow. If the string passed in to \function {pack()} is too
102+ long (longer than the count minus 1), only the leading count-1 bytes of the
103+ string are stored, If the string is shorter than count-1, it is padded
104+ with null bytes so that exactly count bytes in all are used. Note that
105+ for \function {unpack()}, the \character {p} format character consumes count
106+ bytes, but that the string returned can never contain more than 255
107+ characters.
104108
105109For the \character {I}, \character {L}, \character {q} and \character {Q}
106110format characters, the return value is a Python long integer.
0 commit comments