diff --git a/src/App/DocumentPyImp.cpp b/src/App/DocumentPyImp.cpp index 2c3be6c25..7cc4b9f22 100644 --- a/src/App/DocumentPyImp.cpp +++ b/src/App/DocumentPyImp.cpp @@ -83,11 +83,14 @@ PyObject* DocumentPy::save(PyObject * args) PyObject* DocumentPy::saveAs(PyObject * args) { char* fn; - if (!PyArg_ParseTuple(args, "s", &fn)) // convert args: Python->C - return NULL; // NULL triggers exception + if (!PyArg_ParseTuple(args, "et", "utf-8", &fn)) + return NULL; + + std::string utf8Name = fn; + PyMem_Free(fn); try { - if (!getDocumentPtr()->saveAs(fn)) { + if (!getDocumentPtr()->saveAs(utf8Name.c_str())) { PyErr_SetString(PyExc_ValueError, "Object attribute 'FileName' is not set"); return NULL; } @@ -101,9 +104,9 @@ PyObject* DocumentPy::saveAs(PyObject * args) return 0; } - Base::FileInfo fi(fn); + Base::FileInfo fi(utf8Name); if (!fi.isReadable()) { - PyErr_Format(PyExc_IOError, "No such file or directory: '%s'", fn); + PyErr_Format(PyExc_IOError, "No such file or directory: '%s'", utf8Name.c_str()); return NULL; } diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index 15406bdc3..a8bbe86b6 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -670,8 +671,9 @@ bool Document::saveAs(void) // save as new file name try { Gui::WaitCursor wc; - Command::doCommand(Command::Doc,"App.getDocument(\"%s\").saveAs(\"%s\")" - , DocName, (const char*)fn.toUtf8()); + std::string escapedstr = Base::Tools::escapedUnicodeFromUtf8(fn.toUtf8()); + Command::doCommand(Command::Doc,"App.getDocument(\"%s\").saveAs(u\"%s\")" + , DocName, escapedstr.c_str()); setModified(false); getMainWindow()->appendRecentFile(fi.filePath()); }