Skip to content
Snippets Groups Projects
Commit 8660a737 authored by Gigg, Martyn Anthony's avatar Gigg, Martyn Anthony Committed by Martyn Gigg
Browse files

Use non-deprecated unicode conversion function

Refs #16578
parent f90a148c
No related branches found
No related tags found
No related merge requests found
......@@ -24,11 +24,13 @@ boost::shared_ptr<UnitLabel>
createLabel(const object &ascii, const object &utf8, const object &latex) {
using Utf8Char = UnitLabel::Utf8String::value_type;
if (PyUnicode_Check(utf8.ptr())) {
auto length = PyUnicode_GetSize(utf8.ptr());
boost::scoped_array<Utf8Char> buffer(new Utf8Char[length]);
#if PY_MAJOR_VERSION >= 3
auto length = PyUnicode_GetLength(utf8.ptr());
boost::scoped_array<Utf8Char> buffer(new Utf8Char[length]);
PyUnicode_AsWideChar(utf8.ptr(), buffer.get(), length);
#else
auto length = PyUnicode_GetSize(utf8.ptr());
boost::scoped_array<Utf8Char> buffer(new Utf8Char[length]);
PyUnicode_AsWideChar(reinterpret_cast<PyUnicodeObject *>(utf8.ptr()),
buffer.get(), length);
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment