[C++-sig] Creating a unicode instrance from utf-8 encoded string

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Mon Feb 21 17:29:29 CET 2011


>          result.append(PyUnicode_FromString(i->c_str()));


try

result.append(object(handle<>(PyUnicode_FromString(i->c_str()))));

The handle<> is a way to tell Boost.Python if you own the reference or if it is 
borrowed (among other things). The
suggested code assumes you own the reference.

Ralf


More information about the Cplusplus-sig mailing list