We are using C++ on windows and Linux and UNIX and are reading a text file. On Windows with some files we are getting extra spaces between characters in a line. I have seen an article that seems to explain this but we are getting errors.
When we read some files created by applications on Windows there is a space between characters. When we create a text file in Windows it does not have extra spaces.
fstream file;
string fileline;
file.open(configuration_file, ios::in|ios::out);
// This line was added from the post and we get errors
file.imbue(std::locale(file.getloc(), new std::codecvt_utf16<char, 0x10FFFF, std::consume_header>));
if (!file){
print_progress("Configuration File does not exist\n");
}
else {
while(!file.eof()) {
getline(file, fileline);
std::cout << std::string(fileline) + "\n";
}
}
file.close();
How do we resolve this in C++? Is there a library that manages this?
Many thanks