From 9e9a454733bf8d45af2f33a9cb7cc19632079415 Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Mon, 30 Jan 2023 14:49:54 +0800 Subject: [PATCH] fix: Maybe got an error text code on windows --- DSView/pv/utility/path.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/DSView/pv/utility/path.cpp b/DSView/pv/utility/path.cpp index 2a19732f..7ca42322 100644 --- a/DSView/pv/utility/path.cpp +++ b/DSView/pv/utility/path.cpp @@ -22,6 +22,8 @@ #include "path.h" #ifdef _WIN32 #include +#include "../log.h" +#include #endif namespace pv{ @@ -45,13 +47,19 @@ namespace path{ std::string ToUnicodePath(QString path) { std::string str; - + #ifdef _WIN32 - QTextCodec *codec = QTextCodec::codecForLocale(); - QByteArray str_tmp = codec->fromUnicode(path); - str = str_tmp.data(); + QTextCodec *codec = QTextCodec::codecForName("System"); + if (codec != NULL){ + QByteArray str_tmp = codec->fromUnicode(path); + str = str_tmp.data(); + } + else{ + dsv_err("Error: can't get \"System\" page code"); + str = path.toUtf8().data(); + } #else - str = path.toUtf8().data(); + str = path.toUtf8().data(); #endif return str;