Skip to content

Commit

Permalink
fix(log): charset
Browse files Browse the repository at this point in the history
修复log文件上传的路径编码问题
  • Loading branch information
mystringEmpty committed Dec 27, 2024
1 parent 4be4d33 commit f026c08
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Dice/DiceJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,8 @@ void log_put(AttrObject& job) {
"ap-southeast-1");
if (job->at("ret") == "SUCCESS") {
#endif //_Win32
job->at("log_file") = nameLog;
job->at("log_url") = "https://logpainter.kokona.tech/?s3=" + nameLog;
job->set("log_file",nameLog);
job->set("log_url", "https://logpainter.kokona.tech/?s3=" + nameLog);
reply(job, "{strLogUpSuccess}");
}
else if (++cntExec > 2) {
Expand Down
5 changes: 3 additions & 2 deletions Dice/DicePython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ PYDEF(getDiceID) {
}
PYDEF(getDiceDir) {
auto dir{ DiceDir.wstring() };
return PyUnicode_FromUnicode(dir.c_str(), (Py_ssize_t)dir.length());
return PyUnicode_FromWideChar(dir.c_str(), (Py_ssize_t)dir.length());
}
typedef struct {
PyObject_HEAD
Expand Down Expand Up @@ -1170,11 +1170,12 @@ PyGlobal::PyGlobal() {
|| std::filesystem::exists((dirPy = dirExe) / "python3.dll")) {
//Py_SetPythonHome(dirPy.wstring().c_str());
PyConfig_SetString(&config, &config.home, dirPy.wstring().c_str());
//Py_SetProgramName(L"DiceMaid");
PyConfig_SetString(&config, &config.program_name, L"DiceMaid");
//Py_SetPath((dirPy / "python311.zip").wstring().c_str());
PyWideStringList_Append(&config.module_search_paths, (dirPy / "python311.zip").wstring().c_str());
}
status = PyConfig_Read(&config);
Py_SetProgramName(L"DiceMaid");
try {
static auto import_dice = PyImport_AppendInittab(DiceModuleName, PyInit_DiceMaid);
if (import_dice) {
Expand Down
4 changes: 2 additions & 2 deletions Dice/DiceSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void LogInfo::append(const string& s) {
}

bool DiceSession::empty()const {
return dict.empty() && player->empty() && obs->empty() && !logger.tLastMsg && decks.empty();
return dict.empty() && player->empty() && obs->empty() && !logger.tStart && decks.empty();
}
bool DiceSession::has(const string& key)const {
static std::unordered_set<string> items{ "name", "gms", "pls", "obs", "log_name", "log_file" };
Expand Down Expand Up @@ -256,7 +256,7 @@ void DiceSession::log_end(DiceEvent* msg) {
return;
}
msg->set("log_file", logger.fileLog);
msg->set("log_path", log_path().string());
msg->set("log_path", log_path().u8string());
msg->replyMsg("strLogEnd");
update();
msg->set("hook","LogEnd");
Expand Down
4 changes: 2 additions & 2 deletions Dice/EncodingConvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ std::string UTF8toLocal(const std::string& str) {
#ifdef _WIN32
return UTF8toGBK(str);
#else
return str
return str;
#endif
}
std::string GBKtoLocal(const std::string& strGBK){
Expand Down Expand Up @@ -211,7 +211,7 @@ std::wstring UTF8toU(const std::string& strUTF8) {
delete[] strUTF16;
return wstrOut;
#else
return ConvertEncoding<char>(strUTF8, "utf-8", "gb18030");
return ConvertEncoding<wchar_t>(strUTF8, "utf-8", "utf-32le");
#endif
}

Expand Down

0 comments on commit f026c08

Please sign in to comment.