fix encoding issues YET AGAIN

This commit is contained in:
GenevensiS
2026-01-04 01:48:15 +01:00
parent 8cca7674bd
commit dc27a13d8d
+6 -3
View File
@@ -316,9 +316,12 @@ ScriptValueP json_to_mse(const boost::json::value& jv, Set* set) {
else if (jv.is_string()) { else if (jv.is_string()) {
if (jv.as_string().empty()) return to_script(String()); if (jv.as_string().empty()) return to_script(String());
std::string string = boost::json::value_to<std::string>(jv); std::string string = boost::json::value_to<std::string>(jv);
String wxstring = String(string); const char* cstring = string.c_str();
if (wxstring.empty()) wxstring = String(string.c_str(), wxConvUTF8); size_t nulpos = strlen(cstring);
return to_script(wxstring); // 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()) { else if (jv.is_array()) {
boost::json::array array = jv.get_array(); boost::json::array array = jv.get_array();