summaryrefslogtreecommitdiff
path: root/src/pyutils.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-11-20 23:23:44 -0500
committerJohn Wiegley <johnw@newartisans.com>2009-11-20 23:23:44 -0500
commitd5e957204c2799f07f9ecf868d2d846bea5682ef (patch)
treee2618ed53b09e0ea7d0d5871c237ec3b5127faae /src/pyutils.h
parentbd455c98743ce354b875d67a1d607a682d604fe0 (diff)
downloadfork-ledger-d5e957204c2799f07f9ecf868d2d846bea5682ef.tar.gz
fork-ledger-d5e957204c2799f07f9ecf868d2d846bea5682ef.tar.bz2
fork-ledger-d5e957204c2799f07f9ecf868d2d846bea5682ef.zip
Fixed Ledger/Python byte vs. char Unicode bridge
Diffstat (limited to 'src/pyutils.h')
-rw-r--r--src/pyutils.h9
1 files changed, 9 insertions, 0 deletions
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 <typename T>
+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