mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-04 02:41:19 +00:00
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.
This commit is contained in:
parent
ebdcb7acbd
commit
316f666e77
@ -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…
Reference in New Issue
Block a user