How to map python's unicode stuff to a wchar_t based api?

Ames Andreas (MPA/DF) Andreas.Ames at tenovis.com
Mon Apr 26 14:28:26 EDT 2004


Hi all,

besides PyUnicode_(From)|(As)WideChar I haven't found specific support
for wchar_t in the python api.  Is there a default codec that produces
wchar_t* (in a platform-neutral way) or something else in
PyArg_ParseTuple's format string that could help me?  What encoding is
used for python's Py_UNICODE thing?

My specific problem is that I wrap an api where one function can have
as well an ansi as a unicode variant.  I don't want to decide which
variant to use at compile time but rather at runtime.  Therefore I
have a default argument useUnicode and if possible I want to get rid
of the

if (PyObject_IsTrue(useUnicode)) {
   doTheUnicodeStuff();
   ...
}
else {
   doTheAnsiThingWhichLooksAlmostIdenticalToTheAboveButJustAlmost();
   ...
}

annoyance in almost any function.


TIA,

andreas





More information about the Python-list mailing list