bool StdFileManager::GetUTF16FileString(const str_type::string &fileName, str_type::string &out) { FILE* file = 0; errno_t err = _wfopen_s(&file, fileName.c_str(), L"rb"); if (err || !file) { return false; } long length = 0; // const std::size_t wcharSize = sizeof(wchar_t); const std::size_t BOMsize = 2; fseek(file, 0, SEEK_END); length = ftell(file); fseek(file, 0, SEEK_SET); if (length <= 0) { return false; } out.resize(length); unsigned short usOrder; fread(&usOrder, BOMsize, 1, file); if (fread(&out[0], length - BOMsize, 1, file) != 1) { fclose(file); return false; } fclose(file); return true; }
std::vector<str_type::string> splitString(str_type::string str, const str_type::string& c) { std::vector<str_type::string> v; std::size_t pos; while ((pos = str.find(c)) != str_type::string::npos) { v.push_back(str.substr(0, pos)); str = str.substr(pos + c.length(), str_type::string::npos); str.resize(str.length()); } v.push_back(str); return v; }