mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 16:49:54 +00:00
mwiniimporter: use Utf8Encoder
This commit is contained in:
parent
740e2b5769
commit
67273fc177
2 changed files with 4 additions and 10 deletions
|
@ -649,11 +649,13 @@ MwIniImporter::multistrmap MwIniImporter::loadIniFile(std::string filename) {
|
||||||
std::string section("");
|
std::string section("");
|
||||||
MwIniImporter::multistrmap map;
|
MwIniImporter::multistrmap map;
|
||||||
boost::iostreams::stream<boost::iostreams::file_source>file(filename.c_str());
|
boost::iostreams::stream<boost::iostreams::file_source>file(filename.c_str());
|
||||||
|
ToUTF8::Utf8Encoder encoder;
|
||||||
|
encoder.setEncoding(mEncoding);
|
||||||
|
|
||||||
std::string line;
|
std::string line;
|
||||||
while (std::getline(file, line)) {
|
while (std::getline(file, line)) {
|
||||||
|
|
||||||
line = toUTF8(line);
|
line = encoder.getUtf8(line);
|
||||||
|
|
||||||
// unify Unix-style and Windows file ending
|
// unify Unix-style and Windows file ending
|
||||||
if (!(line.empty()) && (line[line.length()-1]) == '\r') {
|
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)
|
void MwIniImporter::setInputEncoding(const ToUTF8::FromType &encoding)
|
||||||
{
|
{
|
||||||
mEncoding = encoding;
|
mEncoding = encoding;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
|
||||||
#include "../../components/to_utf8/to_utf8.hpp"
|
#include <components/to_utf8/to_utf8.hpp>
|
||||||
|
|
||||||
class MwIniImporter {
|
class MwIniImporter {
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue