From d5e957204c2799f07f9ecf868d2d846bea5682ef Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 20 Nov 2009 23:23:44 -0500 Subject: Fixed Ledger/Python byte vs. char Unicode bridge --- src/pyutils.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/pyutils.h') diff --git a/src/pyutils.h b/src/pyutils.h index d8a46527..54d6fa28 100644 --- a/src/pyutils.h +++ b/src/pyutils.h @@ -126,6 +126,15 @@ struct map_value_type_converter } }; +template +PyObject * str_to_py_unicode(const T& str) +{ + using namespace boost::python; + PyObject * pstr = PyString_FromString(str.c_str()); + PyObject * uni = PyUnicode_FromEncodedObject(pstr, "UTF-8", NULL); + return object(handle<>(borrowed(uni))).ptr(); +} + namespace boost { namespace python { // Use expr to create the PyObject corresponding to x -- cgit v1.2.3