Writing an end of string character in Python
Generic Meowbot
meowbot at meowing.net
Fri Jun 1 22:56:53 EDT 2001
Charlie Clark <charlie at begeistert.org> wrote:
> I have a slight bug with the python module for writing attributes in
> BeOS. String values need to be terminated with a "\O" in order for them
> to be correctly read by some applications but I read in PP2E that "\0"
> does not terminate the string in Python. Is there anyway I can force it
> to?
The data in a string object is padded with a NUL, though Python itself
doesn't use it. PyString_AsString() is even documented to work this
way, so if you're not getting that, something is Very Wrong somewhere.
One gotcha is that Python also allows NUL to appear within a string,
so you should ask the Python API what it thinks not rely on strlen()
and the like to return a correct value.
More information about the Python-list
mailing list