From 7a119a5b9e5122cf2f148cfcbe66b10a9de4f258 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 20 May 2013 11:48:13 +0100 Subject: [PATCH] + mapnik_datasource parameters : handle unicode objects - convert to internal UTF8 representation --- bindings/python/mapnik_datasource.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/bindings/python/mapnik_datasource.cpp b/bindings/python/mapnik_datasource.cpp index 95c495aec..07383b372 100644 --- a/bindings/python/mapnik_datasource.cpp +++ b/bindings/python/mapnik_datasource.cpp @@ -48,14 +48,26 @@ namespace { //user-friendly wrapper that uses Python dictionary using namespace boost::python; -boost::shared_ptr create_datasource(const dict& d) +boost::shared_ptr create_datasource(dict const& d) { mapnik::parameters params; boost::python::list keys=d.keys(); - for (int i=0; i(keys[i]); object obj = d[key]; + if (PyUnicode_Check(obj.ptr())) + { + PyObject* temp = PyUnicode_AsUTF8String(obj.ptr()); + if (temp) + { + char* c_str = PyString_AsString(temp); + params[key] = std::string(c_str); + Py_DecRef(temp); + } + continue; + } + extract ex0(obj); extract ex1(obj); extract ex2(obj);