[Python-Dev] unicode/string asymmetries (original) (raw)
M.-A. Lemburg mal@lemburg.com
Thu, 10 Jan 2002 09:49:32 +0100
- Previous message: [Python-Dev] unicode/string asymmetries
- Next message: [Python-Dev] Feature request: better support for "wrapper" objects
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Jack Jansen wrote:
Recently, "M.-A. Lemburg" <mal@lemburg.com> said: > How about this: we add a wchart codec to Python and the "eu#" parser > marker. Then you could write: > > wchart value = NULL; > int len = 0; > if (PyArgParseTuple(tuple, "eu#", "wchart", &value, &len) < 0)_ _> return NULL; I like it! Even though I have to do the memory management myself (and have to think of the error case) it at least looks reasonable.
Good :-)
I'm assuming here that if I pass a StringObject it will be unicode-encoded using the default encoding, and that unicode value will then be converted to wchart and put in value, right? Or, in other words, passing "a.out" will do the same as passing u"a.out"...
Yes.
One minor misgiving is that this call will always copy the string, even if the internal coding of unicode objects is wchart. That's a bit of a nuisance, but we can try to fix that later.
Copying will always take place (either into a preallocated buffer or one which the PyArg_ParseTuple() API allocates), but then: that's the cost you have to pay for the simplicity of the approach.
-- Marc-Andre Lemburg CEO eGenix.com Software GmbH
Company & Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/
- Previous message: [Python-Dev] unicode/string asymmetries
- Next message: [Python-Dev] Feature request: better support for "wrapper" objects
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]