Path and filenames need to use system encoding (fixes #1092).

master
Torsten Paul 2014-12-21 17:11:44 +01:00
parent 8214cabe50
commit c278963a85
2 changed files with 8 additions and 7 deletions

View File

@ -61,11 +61,12 @@ static const std::string getFolderPath(int nFolder)
int result = SHGetFolderPathW( hwndOwner, nFolder, hToken, dwFlags, pszPath );
if (result == S_OK) {
path = std::wstring( path.c_str() ); // strip extra NULLs
//std::wcerr << "wchar path:" << "\n";
const std::string retval = winapi_wstr_to_utf8( path );
//PRINTB("Path found: %s",retval);
return retval;
path = std::wstring( path.c_str() ); // strip extra NULLs
// Use boost::filesystem to decide how to convert from wstring
// to string. Normally the path encoding is system local and
// we don't want to force conversion to UTF-8.
fs::path p(path);
return p.string();
}
return "";
}

View File

@ -1232,7 +1232,7 @@ void MainWindow::writeBackup(QFile *file)
writer.setCodec("UTF-8");
writer << this->editor->toPlainText();
PRINTB("Saved backup file: %s", file->fileName().toLocal8Bit().constData());
PRINTB("Saved backup file: %s", file->fileName().toUtf8().constData());
}
void MainWindow::saveBackup()
@ -1243,7 +1243,7 @@ void MainWindow::saveBackup()
return;
}
QString backupPath = QString::fromStdString(path);
QString backupPath = QString::fromLocal8Bit(path.c_str());
if (!backupPath.endsWith("/")) backupPath.append("/");
QString basename = "unsaved";