From afc7dcd83c2f49e76ddf7db2e746736f783fc605 Mon Sep 17 00:00:00 2001 From: jNullj Date: Fri, 11 Nov 2022 12:21:30 +0200 Subject: [PATCH] Add Unicode support for database filenames on Windows (#8782) Fixes #8751 --- src/main.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 047e44740..47fe55483 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -120,11 +120,12 @@ int main(int argc, char** argv) // Get correct case for Windows filenames (fixes #7139) for (const auto& file : parser.positionalArguments()) { const auto fileInfo = QFileInfo(file); - WIN32_FIND_DATA findFileData; + WIN32_FIND_DATAW findFileData; HANDLE hFind; - hFind = FindFirstFile(fileInfo.absoluteFilePath().toUtf8(), &findFileData); + const wchar_t* absolutePathWchar = reinterpret_cast(fileInfo.absoluteFilePath().utf16()); + hFind = FindFirstFileW(absolutePathWchar, &findFileData); if (hFind != INVALID_HANDLE_VALUE) { - fileNames << QString("%1/%2").arg(fileInfo.absolutePath(), QString::fromUtf8(findFileData.cFileName)); + fileNames << QString("%1/%2").arg(fileInfo.absolutePath(), QString::fromWCharArray(findFileData.cFileName)); FindClose(hFind); } }