fixes 0003521: Import of csv file into Spreadsheet does not work if the path contains non ASCII characters

This commit is contained in:
wmayer
2018-09-24 22:16:48 +02:00
parent 1b7708a391
commit 511ddfffa1
2 changed files with 10 additions and 5 deletions

View File

@@ -73,17 +73,19 @@ public:
private:
Py::Object open(const Py::Tuple& args)
{
const char* Name;
char* Name;
const char* DocName=0;
if (!PyArg_ParseTuple(args.ptr(), "s|s",&Name,&DocName))
if (!PyArg_ParseTuple(args.ptr(), "et|s","utf-8",&Name,&DocName))
throw Py::Exception();
std::string EncodedName = std::string(Name);
PyMem_Free(Name);
try {
Base::FileInfo file(Name);
Base::FileInfo file(EncodedName);
App::Document *pcDoc = App::GetApplication().newDocument(DocName ? DocName : QT_TR_NOOP("Unnamed"));
Spreadsheet::Sheet *pcSheet = static_cast<Spreadsheet::Sheet *>(pcDoc->addObject("Spreadsheet::Sheet", file.fileNamePure().c_str()));
pcSheet->importFromFile(Name, '\t', '"', '\\');
pcSheet->importFromFile(EncodedName, '\t', '"', '\\');
pcSheet->execute();
}
catch (const Base::Exception& e) {