I am having an issue with "umlauts" (letters ä, ü, ö, ...) and ifstream in C++.
I use curl to download an html page and ifstream to read in the downloaded file line by line and parse some data out of it. This goes well until I have a line like one of the following:
te="Olimpija Laibach - Tromsö";
te="Burghausen - Münster";
My code parses these lines and outputs it as the following:
Olimpija Laibach vs. Troms?
Burghausen vs. M?nster
Things like outputting umlauts directly from the code work:
cout << "öäü" << endl; // This works fine
My code looks somewhat like this:
ifstream fin("file");
while(!(fin.eof())) {
getline(fin, line, '\n');
int pos = line.find("te=");
if(pos >= 0) {
pos = line.find(" - ");
string team1 = line.substr(4,pos-4);
string team2 = line.substr(pos+3, line.length()-pos-6);
cout << team1 << " vs. " << team2 << endl;
}
}
Edit: The weird thing is that the same code (the only changed things are the source and the delimiters) works for another text input file (same procedure: download with curl, read with ifstream). Parsing and outputting a line like the following is no problem:
<span id="...">Fernwärme Vienna</span>