summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2023-10-07 18:49:27 +0200
committerGitHub <noreply@github.com>2023-10-07 18:49:27 +0200
commit0e9b839b6f5e10ea35ee3db79226fcc535c90064 (patch)
tree08825c9526eaf9bd8f981ddbd84e44ad36f3a877 /src/core
parentMerge pull request #11544 from Kelebek1/reduce_stream_buffer_renderdoc (diff)
parentgdbserver: use numeric character references for unicode (diff)
downloadyuzu-0e9b839b6f5e10ea35ee3db79226fcc535c90064.tar
yuzu-0e9b839b6f5e10ea35ee3db79226fcc535c90064.tar.gz
yuzu-0e9b839b6f5e10ea35ee3db79226fcc535c90064.tar.bz2
yuzu-0e9b839b6f5e10ea35ee3db79226fcc535c90064.tar.lz
yuzu-0e9b839b6f5e10ea35ee3db79226fcc535c90064.tar.xz
yuzu-0e9b839b6f5e10ea35ee3db79226fcc535c90064.tar.zst
yuzu-0e9b839b6f5e10ea35ee3db79226fcc535c90064.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/debugger/gdbstub.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/core/debugger/gdbstub.cpp b/src/core/debugger/gdbstub.cpp
index e55831f27..82964f0a1 100644
--- a/src/core/debugger/gdbstub.cpp
+++ b/src/core/debugger/gdbstub.cpp
@@ -2,6 +2,8 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include <atomic>
+#include <codecvt>
+#include <locale>
#include <numeric>
#include <optional>
#include <thread>
@@ -12,6 +14,7 @@
#include "common/logging/log.h"
#include "common/scope_exit.h"
#include "common/settings.h"
+#include "common/string_util.h"
#include "core/arm/arm_interface.h"
#include "core/core.h"
#include "core/debugger/gdbstub.h"
@@ -68,10 +71,16 @@ static std::string EscapeGDB(std::string_view data) {
}
static std::string EscapeXML(std::string_view data) {
+ std::u32string converted = U"[Encoding error]";
+ try {
+ converted = Common::UTF8ToUTF32(data);
+ } catch (std::range_error&) {
+ }
+
std::string escaped;
escaped.reserve(data.size());
- for (char c : data) {
+ for (char32_t c : converted) {
switch (c) {
case '&':
escaped += "&amp;";
@@ -86,7 +95,11 @@ static std::string EscapeXML(std::string_view data) {
escaped += "&gt;";
break;
default:
- escaped += c;
+ if (c > 0x7f) {
+ escaped += fmt::format("&#{};", static_cast<u32>(c));
+ } else {
+ escaped += static_cast<char>(c);
+ }
break;
}
}