mirror of
https://github.com/lltcggie/waifu2x-caffe.git
synced 2025-06-26 13:42:48 +00:00
言語ファイルのUTF-8のBOMがついていても大丈夫なようにした
This commit is contained in:
parent
6f39c40aba
commit
4a1e635991
@ -125,7 +125,11 @@ private:
|
||||
|
||||
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())
|
||||
throw 0;
|
||||
@ -163,9 +167,16 @@ public:
|
||||
|
||||
LangList.clear();
|
||||
|
||||
bool isFirst = true;
|
||||
|
||||
std::string 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() == ';')
|
||||
continue;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user