summaryrefslogtreecommitdiff
path: root/src/pyutils.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-11-21 15:19:42 -0500
committerJohn Wiegley <johnw@newartisans.com>2009-11-21 15:19:42 -0500
commitf01fa1a5131c287a4efe2708ffe3c9bc57b79468 (patch)
tree2a2f732edd59c4f42c1eb3e9a9e95ff135091bab /src/pyutils.h
parent117dddabd4f883de4f464821f9567d889a6fa449 (diff)
parentacb24d6d22e19d4f6b3883c029dd9fef5c1c9529 (diff)
downloadfork-ledger-f01fa1a5131c287a4efe2708ffe3c9bc57b79468.tar.gz
fork-ledger-f01fa1a5131c287a4efe2708ffe3c9bc57b79468.tar.bz2
fork-ledger-f01fa1a5131c287a4efe2708ffe3c9bc57b79468.zip
Merge branch 'next'
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