From dc27a13d8d6636c612169f1654c327d4d234ff77 Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Sun, 4 Jan 2026 01:48:15 +0100 Subject: [PATCH] fix encoding issues YET AGAIN --- src/script/functions/json.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/script/functions/json.cpp b/src/script/functions/json.cpp index 967fa84e..74817680 100644 --- a/src/script/functions/json.cpp +++ b/src/script/functions/json.cpp @@ -316,9 +316,12 @@ ScriptValueP json_to_mse(const boost::json::value& jv, Set* set) { else if (jv.is_string()) { if (jv.as_string().empty()) return to_script(String()); std::string string = boost::json::value_to(jv); - String wxstring = String(string); - if (wxstring.empty()) wxstring = String(string.c_str(), wxConvUTF8); - return to_script(wxstring); + const char* cstring = string.c_str(); + size_t nulpos = strlen(cstring); + // if the string contains nul bytes, we have to use the std::string constructor, even though we can't specify the encoding + if (nulpos < string.size()) return to_script(String(string)); + // if the string doesn't contain nul bytes, we can use the constructor that allows to specify the encoding + else return to_script(String(cstring, wxConvUTF8)); } else if (jv.is_array()) { boost::json::array array = jv.get_array();