2
0
forked from Ivasoft/DSView

fix: Maybe got an error text code on windows

This commit is contained in:
dreamsourcelabTAI
2023-01-30 14:49:54 +08:00
parent 98075b4a4f
commit 9e9a454733

View File

@@ -22,6 +22,8 @@
#include "path.h"
#ifdef _WIN32
#include <QTextCodec>
#include "../log.h"
#include <string.h>
#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;