Skip to content

Commit

Permalink
Merge pull request hengband#4424 from habu1010/feature/fix-error-repo…
Browse files Browse the repository at this point in the history
…rt-garbled-text

[Fix] エラーレポートの文字化け
  • Loading branch information
habu1010 authored Jul 20, 2024
2 parents f4bcdc6 + 563284f commit 722c7c0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main-win/main-win-exception.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "main-win/main-win-exception.h"
#include "locale/japanese.h"
#include "main-win/main-win-utils.h"
#include "net/report-error.h"
#include <sstream>
Expand All @@ -15,7 +16,13 @@ void handle_unexpected_exception(const std::exception &e)
{
constexpr auto caption = _(L"予期しないエラー!", L"Unexpected error!");

const std::string msg = e.what();
std::string msg = e.what();
#ifdef JP
// 例外メッセージがUTF-8の場合一旦SJISに変換する(SJISの場合はそのまま)
const auto msg_len = guess_convert_to_system_encoding(msg.data(), msg.size());
msg.erase(msg_len);
#endif

const auto first_line = msg.substr(0, msg.find('\n'));

#if !defined(DISABLE_NET)
Expand Down

0 comments on commit 722c7c0

Please sign in to comment.