PyArg_ParseTuple and Unicode
Scottie
me at nospam.net
Thu Oct 18 09:23:55 EDT 2001
I am confused here, but this is not uncommon. I am trying to get an
extension to handle both normal strings and unicode. From my initial
reading of the PyArg_ParseTuple document, I thought the following
would work:
if( PyArg_ParseTuple(arg, "...u#...", ...) ) {
...Unicode ops...
}
else if( PyArg_ParseTuple(arg, "...s#...", ...) ) {
...plain string ops...
}
My understanding of "u" and "u#" was that they would fail on non-
unicode input (while "s" and "s#" pass both along). The behavior I
see is different: "u#" gives me a pointer to the base of a vanilla
string, but divides the length by two.
Is this problem behavior in 2.2a4, or does the document need to
explain this better, or is there something I am just not understanding?
Or, of course, some combination of the three.
Thanks,
Scott David Daniels,
Scott.Daniels at Acm.Org
More information about the Python-list
mailing list