[Python-Dev] unicode/string asymmetries

M.-A. Lemburg mal@lemburg.com
2002年1月09日 17:45:19 +0100


Jack Jansen wrote:
> ...
> So, I would like PyArg_Parse/Py_BuildValue formats that are symmetric to "s",
> "s#" and "z" but that return wchar_t strings and that work with both
> UnicodeObjects and StringObjects.

How about this: we add a wchar_t codec to Python and the "eu#" parser
marker. Then you could write:
	wchar_t value = NULL;
	int len = 0;
	if (PyArg_ParseTuple(tuple, "eu#", "wchar_t", &value, &len) < 0)
 return NULL;
 
	...
	PyMem_Free(value);
	return ...
or, for 8-bit strings:
	char value = NULL;
	int len = 0;
	if (PyArg_ParseTuple(tuple, "es#", "latin-1", &value, &len) < 0)
 return NULL;
 
	...
	PyMem_Free(value);
	return ...
Is that symmetric enough ?
-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Company & Consulting: http://www.egenix.com/
Python Software: http://www.egenix.com/files/python/

AltStyle によって変換されたページ (->オリジナル) /