Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
88091aae
Commit
88091aae
authored
Sep 15, 2001
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SF bug [#461674] struct 'p' format doesn't work (maybe)
Rewrote the 'p' description.
parent
e0007821
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
Doc/lib/libstruct.tex
Doc/lib/libstruct.tex
+11
-7
No files found.
Doc/lib/libstruct.tex
View file @
88091aae
...
@@ -94,13 +94,17 @@ For unpacking, the resulting string always has exactly the specified
...
@@ -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
number of bytes. As a special case,
\code
{
'0s'
}
means a single, empty
string (while
\code
{
'0c'
}
means 0 characters).
string (while
\code
{
'0c'
}
means 0 characters).
The
\character
{
p
}
format character can be used to encode a Pascal
The
\character
{
p
}
format character encodes a "Pascal string", meaning
string. The first byte is the length of the stored string, with the
a short variable-length string stored in a fixed number of bytes.
bytes of the string following. If count is given, it is used as the
The count is the total number of bytes stored. The first byte stored is
total number of bytes used, including the length byte. If the string
the length of the string, or 255, whichever is smaller. The bytes
passed in to
\function
{
pack()
}
is too long, the stored representation
of the string follow. If the string passed in to
\function
{
pack()
}
is too
is truncated. If the string is too short, padding is used to ensure
long (longer than the count minus 1), only the leading count-1 bytes of the
that exactly enough bytes are used to satisfy the count.
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
}
For the
\character
{
I
}
,
\character
{
L
}
,
\character
{
q
}
and
\character
{
Q
}
format characters, the return value is a Python long integer.
format characters, the return value is a Python long integer.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment