Handle non-ASCII characters while saving without triggering an assertion

pull/3224/head
Evil Eye 3 years ago
parent 29847655f6
commit 8f48a1f030

@ -75,6 +75,7 @@
Bug #6363: Some scripts in Morrowland fail to work
Bug #6376: Creatures should be able to use torches
Bug #6386: Artifacts in water reflection due to imprecise screen-space coordinate computation
Bug #6396: Inputting certain Unicode characters triggers an assertion
Bug #6416: Morphs are applied to the wrong target
Feature #890: OpenMW-CS: Column filtering
Feature #2554: Modifying an object triggers the instances table to scroll to the corresponding record

@ -8,6 +8,8 @@
#include <components/esm/esmreader.hpp>
#include <components/esm/defs.hpp>
#include <components/misc/utf8stream.hpp>
bool MWState::operator< (const Slot& left, const Slot& right)
{
return left.mTimeStamp<right.mTimeStamp;
@ -52,12 +54,14 @@ void MWState::Character::addSlot (const ESM::SavedGame& profile)
std::ostringstream stream;
// The profile description is user-supplied, so we need to escape the path
for (std::string::const_iterator it = profile.mDescription.begin(); it != profile.mDescription.end(); ++it)
Utf8Stream description(profile.mDescription);
while(!description.eof())
{
if (std::isalnum(*it)) // Ignores multibyte characters and non alphanumeric characters
stream << *it;
auto c = description.consume();
if(c > 0 && c <= 0x7F && std::isalnum(c)) // Ignore multibyte characters and non alphanumeric characters
stream << static_cast<char>(c);
else
stream << "_";
stream << '_';
}
const std::string ext = ".omwsave";

@ -30,6 +30,11 @@ public:
{
}
Utf8Stream (const std::string& str) :
Utf8Stream (reinterpret_cast<Point>(str.c_str()), reinterpret_cast<Point>(str.c_str() + str.size()))
{
}
bool eof () const
{
return cur == end;

Loading…
Cancel
Save