[C++-sig] automatic conversion from python unicode object to C++ std::string?

John Reid j.reid at mail.cryst.bbk.ac.uk
Fri Aug 12 13:36:15 CEST 2011


I recently upgraded to ipython 0.11. In 0.11 sys.argv entries are of 
type unicode rather than string. All of my scripts that call into 
boost.python extensions fail as my exposed functions expect arguments of 
type std::string. Presumably I could recode all my functions to use 
std::wstring and everything would work. This would be a lot of work so 
for the moment, I'm encoding everything in python from unicode to 
strings. I was wondering if there is a simple way to tell my 
boost.python extensions to do this encoding automatically.

Thanks,
John.



More information about the Cplusplus-sig mailing list