modified esm reader/writer to use UTF8 when no encoder is given

pull/22/head
Marc Zinnschlag 11 years ago
parent 903e867c24
commit 35bf98a940

@ -303,7 +303,10 @@ std::string ESMReader::getString(int size)
getExact(ptr, size);
// Convert to UTF8 and return
return mEncoder->getUtf8(ptr, size);
if (mEncoder)
return mEncoder->getUtf8(ptr, size);
return std::string (ptr, size);
}
void ESMReader::fail(const std::string &msg)

@ -6,7 +6,7 @@
namespace ESM
{
ESMWriter::ESMWriter() : mRecordCount (0), mCounting (true) {}
ESMWriter::ESMWriter() : mEncoder (0), mRecordCount (0), mCounting (true) {}
unsigned int ESMWriter::getVersion() const
{
@ -152,9 +152,9 @@ namespace ESM
else
{
// Convert to UTF8 and return
std::string ascii = mEncoder->getLegacyEnc(data);
std::string string = mEncoder ? mEncoder->getLegacyEnc(data) : data;
write(ascii.c_str(), ascii.size());
write(string.c_str(), string.size());
}
}

Loading…
Cancel
Save