How to convert unicode string to unsigned char *

"Martin v. Löwis" martin at v.loewis.de
Mon May 5 12:33:39 EDT 2008


> some_module.some_thing(the_string) function is a swig generated
> function from a C lib. The C lib function expects unsigned char *.
> 
> The generated function is:

If you don't want to change the generated function, I recommend to
put a wrapper around it, as Jean-Paul suggested:

def some_thing(s):
  return some_thing_real(s.encode("utf-8"))

Regards,
Martin



More information about the Python-list mailing list