言語ファイルのUTF-8のBOMがついていても大丈夫なようにした

This commit is contained in:
lltcggie 2016-04-20 19:02:16 +09:00
parent 6f39c40aba
commit 4a1e635991

View File

@ -125,7 +125,11 @@ private:
jsonBuf[jsonBuf.size() - 1] = '\0'; jsonBuf[jsonBuf.size() - 1] = '\0';
d.Parse(jsonBuf.data()); const char *data = jsonBuf.data();
if (jsonBuf.size() > 3 && (unsigned char)data[0] == 0xEF && (unsigned char)data[1] == 0xBB && (unsigned char)data[2] == 0xBF)
data += 3;
d.Parse(data);
if (d.HasParseError()) if (d.HasParseError())
throw 0; throw 0;
@ -163,9 +167,16 @@ public:
LangList.clear(); LangList.clear();
bool isFirst = true;
std::string str; std::string str;
while (getline(ifs, str)) while (getline(ifs, str))
{ {
if (isFirst && str.size() > 3 && (unsigned char)str[0] == 0xEF && (unsigned char)str[1] == 0xBB && (unsigned char)str[2] == 0xBF)
str.erase(0, 3);
isFirst = false;
if (str.length() > 0 && str.front() == ';') if (str.length() > 0 && str.front() == ';')
continue; continue;