diff --git a/bindings/python/mapnik_feature.cpp b/bindings/python/mapnik_feature.cpp index 00aeecd9b..32dfd2763 100644 --- a/bindings/python/mapnik_feature.cpp +++ b/bindings/python/mapnik_feature.cpp @@ -27,6 +27,7 @@ #include #include #include +#include // mapnik #include @@ -47,7 +48,16 @@ namespace boost { namespace python { PyObject * operator() (UnicodeString const& s) const { - return ::PyUnicode_FromWideChar((wchar_t*)s.getBuffer(),implicit_cast(s.length())); + int32_t len = s.length(); + boost::scoped_array buf(new wchar_t(len)); + UErrorCode err = U_ZERO_ERROR; + u_strToWCS(buf.get(),len,0,s.getBuffer(),len,&err); + PyObject *obj = Py_None; + if (U_SUCCESS(err)) + { + obj = ::PyUnicode_FromWideChar(buf.get(),implicit_cast(len)); + } + return obj; } PyObject * operator() (mapnik::value_null const& s) const