mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-06 09:39:49 +00:00
mwiniimporter: use Utf8Encoder
This commit is contained in:
parent
740e2b5769
commit
67273fc177
@ -649,11 +649,13 @@ MwIniImporter::multistrmap MwIniImporter::loadIniFile(std::string filename) {
|
||||
std::string section("");
|
||||
MwIniImporter::multistrmap map;
|
||||
boost::iostreams::stream<boost::iostreams::file_source>file(filename.c_str());
|
||||
ToUTF8::Utf8Encoder encoder;
|
||||
encoder.setEncoding(mEncoding);
|
||||
|
||||
std::string line;
|
||||
while (std::getline(file, line)) {
|
||||
|
||||
line = toUTF8(line);
|
||||
line = encoder.getUtf8(line);
|
||||
|
||||
// unify Unix-style and Windows file ending
|
||||
if (!(line.empty()) && (line[line.length()-1]) == '\r') {
|
||||
@ -829,14 +831,6 @@ void MwIniImporter::writeToFile(boost::iostreams::stream<boost::iostreams::file_
|
||||
}
|
||||
}
|
||||
|
||||
std::string MwIniImporter::toUTF8(const std::string &str) {
|
||||
char *ptr = ToUTF8::getBuffer(str.length());
|
||||
strncpy(ptr, str.c_str(), str.length());
|
||||
|
||||
// Convert to UTF8 and return
|
||||
return ToUTF8::getUtf8(mEncoding);
|
||||
}
|
||||
|
||||
void MwIniImporter::setInputEncoding(const ToUTF8::FromType &encoding)
|
||||
{
|
||||
mEncoding = encoding;
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <vector>
|
||||
#include <exception>
|
||||
|
||||
#include "../../components/to_utf8/to_utf8.hpp"
|
||||
#include <components/to_utf8/to_utf8.hpp>
|
||||
|
||||
class MwIniImporter {
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user