Better handling of detecting csv separator.
This commit is contained in:
		| @@ -12,6 +12,10 @@ static bool IsKeyValid(const std::string_view & key){ | |||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | const char PossibleSeparators[] = { | ||||||
|  |     ',', ';', '|', '\t', ':' | ||||||
|  | }; | ||||||
|  |  | ||||||
| void LocalizationFile::LoadFile(const std::filesystem::path& path) { | void LocalizationFile::LoadFile(const std::filesystem::path& path) { | ||||||
|     if (!std::filesystem::exists(path)) { |     if (!std::filesystem::exists(path)) { | ||||||
|         std::stringstream ss; |         std::stringstream ss; | ||||||
| @@ -31,9 +35,11 @@ void LocalizationFile::LoadFile(const std::filesystem::path& path) { | |||||||
|     while (std::getline(file, line)) { |     while (std::getline(file, line)) { | ||||||
|         if (firstLine) { |         if (firstLine) { | ||||||
|             firstLine = false; |             firstLine = false; | ||||||
|             if (line.substr(0, 4) == "sep=") { |             for (auto& s :PossibleSeparators) { | ||||||
|                 sep = line[4]; |                 if (line.find(s) != std::string::npos){ | ||||||
|                 continue; |                     sep = s; | ||||||
|  |                     break; | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         std::string key; |         std::string key; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user