1
0
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:
elsid 2022-07-01 22:29:36 +02:00
parent ebdcb7acbd
commit 316f666e77
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625
2 changed files with 4 additions and 3 deletions

View File

@ -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);

View File

@ -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);
}