[C++-sig] Passing std::wstring to Python callback

Bogdan Cristea cristeab at gmail.com
Wed Mar 18 22:25:06 CET 2015


Hi

I am using boost python for providing python bindings for a C++ library. I am using Python 2.7. My library needs to call callbacks that are defined in Python. There callbacks can take a string parameter. C++ side I am always using std::wstring. Everything works on as long as std::wstring contains only ASCII chars, but once I get something like “é” my application crashes. This issue seems to be related to the way I pass std::wstring to Python callbacks: as long as I make sure that the passed string has only ASCII chars it is ok. My problem is how do I pass unicode strings to Python.

thanks
Bogdan  


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20150318/4b53a3f9/attachment.html>


More information about the Cplusplus-sig mailing list