Writing python module in C: wchar_t or Py_UNICODE?

Yury yb at icmail.net
Fri Mar 16 07:04:25 EDT 2007


I am new to python and programming generally, but someday it is time
to start :)
I am writing a python module in C and have a question about multibyte
character strings in python<=>C.
I want a C function which takes a string as argument from python
script:

static PyObject *
connect_to_server(PyObject *self, PyObject * authinfo){
wchar_t * login;  /* Must support unicode */
char * serveraddr;
int * port;

if(!PyArgsParseTuple(authinfo, "sdu", &serveraddr, &port, &login))
return NULL;

...

Will that code work?
Or i should use Py_UNICODE * data type? Will it be compatible with
standard C string comparison/concantenation functions?




More information about the Python-list mailing list