+ fixes unicode support in expression engine
This commit is contained in:
parent
12050b4c7d
commit
29c8e82dae
|
@ -172,6 +172,20 @@ PyObject* DocumentObjectPy::setExpression(PyObject * args)
|
||||||
|
|
||||||
getDocumentObjectPtr()->setExpression(p, shared_expr, comment);
|
getDocumentObjectPtr()->setExpression(p, shared_expr, comment);
|
||||||
}
|
}
|
||||||
|
else if (PyUnicode_Check(expr)) {
|
||||||
|
PyObject* unicode = PyUnicode_AsEncodedString(expr, "utf-8", 0);
|
||||||
|
if (unicode) {
|
||||||
|
std::string exprStr = PyString_AsString(unicode);
|
||||||
|
Py_DECREF(unicode);
|
||||||
|
boost::shared_ptr<Expression> shared_expr(ExpressionParser::parse(getDocumentObjectPtr(), exprStr.c_str()));
|
||||||
|
|
||||||
|
getDocumentObjectPtr()->setExpression(p, shared_expr, comment);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// utf-8 encoding failed
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
throw Py::TypeError("String or None expected.");
|
throw Py::TypeError("String or None expected.");
|
||||||
Py_Return;
|
Py_Return;
|
||||||
|
|
|
@ -112,7 +112,7 @@ bool ExpressionBinding::apply(const std::string & propName)
|
||||||
if (!docObj)
|
if (!docObj)
|
||||||
throw Base::Exception("Document object not found.");
|
throw Base::Exception("Document object not found.");
|
||||||
|
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.getDocument('%s').%s.setExpression('%s', '%s')",
|
Gui::Command::doCommand(Gui::Command::Doc,"App.getDocument('%s').%s.setExpression('%s', u'%s')",
|
||||||
docObj->getDocument()->getName(),
|
docObj->getDocument()->getName(),
|
||||||
docObj->getNameInDocument(),
|
docObj->getNameInDocument(),
|
||||||
path.toEscapedString().c_str(),
|
path.toEscapedString().c_str(),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user