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