Avoid constructing icu::StringPiece from std::string directly

Otherwise it causes a crash on Windows when OpenMW is built in debug
mode but ICU not.
post_malone
elsid 2 years ago
parent ebdcb7acbd
commit 316f666e77
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -75,7 +75,7 @@ namespace l10n
{
const auto key = it.first.as<std::string>();
const auto value = it.second.as<std::string>();
icu::UnicodeString pattern = icu::UnicodeString::fromUTF8(value);
icu::UnicodeString pattern = icu::UnicodeString::fromUTF8(icu::StringPiece(value.data(), value.size()));
icu::ErrorCode status;
UParseError parseError;
icu::MessageFormat message(pattern, lang, parseError, status);
@ -112,7 +112,7 @@ namespace l10n
std::vector<icu::Formattable> argValues;
for (auto& [k, v] : args)
{
argNames.push_back(icu::UnicodeString::fromUTF8(k));
argNames.push_back(icu::UnicodeString::fromUTF8(icu::StringPiece(k.data(), k.size())));
argValues.push_back(v);
}
return formatMessage(key, argNames, argValues);

@ -68,7 +68,8 @@ namespace LuaUtil
}
// Argument names
argNames.push_back(icu::UnicodeString::fromUTF8(key.as<std::string>()));
const auto str = key.as<std::string>();
argNames.push_back(icu::UnicodeString::fromUTF8(icu::StringPiece(str.data(), str.size())));
}
return std::make_pair(args, argNames);
}

Loading…
Cancel
Save