mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2025-01-18 10:26:15 +01:00
Detect and ignore the BOM in the letters file
This commit is contained in:
parent
23771f3f71
commit
1e543111e9
2 changed files with 11 additions and 0 deletions
|
@ -65,6 +65,8 @@ public:
|
|||
bool isVowel, bool isConsonant,
|
||||
const vector<wstring> &iInputs);
|
||||
|
||||
unsigned getLettersCount() const { return m_headerInfo.letters.size(); }
|
||||
|
||||
/**
|
||||
* Generate the dictionary. You must have called addLetter() before
|
||||
* (once for each letter of the word list, and possible once for the
|
||||
|
|
|
@ -70,6 +70,15 @@ void readLetters(const string &iFileName, CompDic &ioBuilder)
|
|||
if (line == "" || line == "\r" || line == "\n")
|
||||
continue;
|
||||
|
||||
// If there is a BOM in the file, remove it from the first line
|
||||
if (ioBuilder.getLettersCount() == 0 && line.size() >= 3 &&
|
||||
(uint8_t)line[0] == 0xEF &&
|
||||
(uint8_t)line[1] == 0xBB &&
|
||||
(uint8_t)line[2] == 0xBF)
|
||||
{
|
||||
line = line.substr(3);
|
||||
}
|
||||
|
||||
// Convert the line to a wstring
|
||||
const wstring &wline =
|
||||
readFromUTF8(line.c_str(), line.size(), "readLetters (1)");
|
||||
|
|
Loading…
Reference in a new issue