How to convert unicode string to unsigned char *

S

Simon Posnjak

Hi!

I have a C module for which I created a wrapper with swig. The function def is:

C:

int some_thing(unsigned char * the_str);

eg:

Python:

some_module.some_thing (the_str)

Now I would like to feed it with a UTF-8 formatted string:

test = u'Make \u0633\u0644\u0627\u0645, not war.'

If I try:

some_module.some_thing (test)

I get:

TypeError with message: in method 'some_thing', argument 1 of type
'unsigned char *'

I also tried to pack the string into array or struct but I can not get
it to work.

What would be the best solution for this problem?

[I am working on Windows]

Regards Simon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top