1 // Common/ListFileUtils.cpp
5 #include "../Windows/FileIO.h"
7 #include "ListFileUtils.h"
8 #include "StringConvert.h"
9 #include "UTFConvert.h"
11 static const char kQuoteChar = '\"';
12 static void RemoveQuote(UString &s)
15 if (s[0] == kQuoteChar && s[s.Length() - 1] == kQuoteChar)
16 s = s.Mid(1, s.Length() - 2);
19 bool ReadNamesFromListFile(LPCWSTR fileName, UStringVector &resultStrings, UINT codePage)
21 NWindows::NFile::NIO::CInFile file;
22 if (!file.Open(fileName))
25 if (!file.GetLength(length))
27 if (length > ((UInt32)1 << 31))
30 char *p = s.GetBuffer((int)length + 1);
32 if (!file.Read(p, (UInt32)length, processed))
34 p[(UInt32)length] = 0;
40 if (codePage == CP_UTF8)
42 if (!ConvertUTF8ToUnicode(s, u))
47 u = MultiByteToUnicodeString(s, codePage);
55 for(int i = 0; i < u.Length(); i++)
58 if (c == L'\n' || c == 0xD)