summaryrefslogtreecommitdiffstats
path: root/Doc/lib/libstruct.tex
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-09-15 18:09:22 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-09-15 18:09:22 (GMT)
commit88091aae7e37dd889743be0a734ff7d4618e0ef7 (patch)
tree11d9767d3a4a69810767e5d2263b0cd4b438fff1 /Doc/lib/libstruct.tex
parente0007821cd2b8db1ecde561929f685bb356d0209 (diff)
downloadcpython-88091aae7e37dd889743be0a734ff7d4618e0ef7.zip
cpython-88091aae7e37dd889743be0a734ff7d4618e0ef7.tar.gz
cpython-88091aae7e37dd889743be0a734ff7d4618e0ef7.tar.bz2
SF bug [#461674] struct 'p' format doesn't work (maybe)
Rewrote the 'p' description.
Diffstat (limited to 'Doc/lib/libstruct.tex')
-rw-r--r--Doc/lib/libstruct.tex18
1 files changed, 11 insertions, 7 deletions
diff --git a/Doc/lib/libstruct.tex b/Doc/lib/libstruct.tex
index 6de67cc..8d0ae60 100644
--- a/Doc/lib/libstruct.tex
+++ b/Doc/lib/libstruct.tex
@@ -94,13 +94,17 @@ For unpacking, the resulting string always has exactly the specified
number of bytes. As a special case, \code{'0s'} means a single, empty
string (while \code{'0c'} means 0 characters).
-The \character{p} format character can be used to encode a Pascal
-string. The first byte is the length of the stored string, with the
-bytes of the string following. If count is given, it is used as the
-total number of bytes used, including the length byte. If the string
-passed in to \function{pack()} is too long, the stored representation
-is truncated. If the string is too short, padding is used to ensure
-that exactly enough bytes are used to satisfy the count.
+The \character{p} format character encodes a "Pascal string", meaning
+a short variable-length string stored in a fixed number of bytes.
+The count is the total number of bytes stored. The first byte stored is
+the length of the string, or 255, whichever is smaller. The bytes
+of the string follow. If the string passed in to \function{pack()} is too
+long (longer than the count minus 1), only the leading count-1 bytes of the
+string are stored, If the string is shorter than count-1, it is padded
+with null bytes so that exactly count bytes in all are used. Note that
+for \function{unpack()}, the \character{p} format character consumes count
+bytes, but that the string returned can never contain more than 255
+characters.
For the \character{I}, \character{L}, \character{q} and \character{Q}
format characters, the return value is a Python long integer.