mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-21 18:40:01 +00:00
Fix conversion to UTF8 for ESM4 Reader strings
toUtf8 returns a string view to the input when input string is ASCII and nothing is written to the buffer which means output string of Reader::getStringImpl is not modified. Move input to the output string and resize it in this case.
This commit is contained in:
parent
80d52e3da8
commit
4f7dcd5ae5
@ -652,7 +652,12 @@ bool Reader::getStringImpl(std::string& str, std::size_t size,
|
|||||||
stream.read(input.data(), size);
|
stream.read(input.data(), size);
|
||||||
if (stream.gcount() == static_cast<std::streamsize>(size))
|
if (stream.gcount() == static_cast<std::streamsize>(size))
|
||||||
{
|
{
|
||||||
encoder->getUtf8(input, ToUTF8::BufferAllocationPolicy::FitToRequiredSize, str);
|
const std::string_view result = encoder->getUtf8(input, ToUTF8::BufferAllocationPolicy::FitToRequiredSize, str);
|
||||||
|
if (str.empty() && !result.empty())
|
||||||
|
{
|
||||||
|
str = std::move(input);
|
||||||
|
str.resize(result.size());
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user