Reputation: 23
The code snippet below causes bad result:
void CTesterDlg::OnClickedButtonTest()
{
CStdioFile myfile;
CString strLine1;
CString strLine2;
myfile.Open(_T("D:\Test1.csv"), CFile::modeWrite | CFile::modeCreate);
strLine1 = L"01001,01001,2017-09-22,09:38:18.6,Alarm,STEERING PORT A – NO DATA RECEIVED,,,,0.0,Normal,0,1,0, ,127,0\n";
strLine2 = L"Monkey, Animal\n";
myfile.WriteString(strLine2);
myfile.WriteString(strLine1);
myfile.WriteString(strLine2);
myfile.Close();
}
when looking inside Test1.csv file
Monkey, Animal
01001,01001,2017-09-22,09:38:18.6,Alarm,STEERING PORT A
Monkey, Animal
everything of the strLine1
after
"..PORT A" " – NO> DATA RECEIVED,,,,0.0,Normal,0,1,0, ,127,0\n"
was deleted ? Any ideas are welcome.
Upvotes: 2
Views: 467
Reputation: 13387
You have a string encoding problem. Notices that the –
in your source code is an En-dash (Unicode code point U+2013), not a Hyphen-Minus. Change it to a Hyphen-Minus (Unicode code point U+002D) and your text should show up in the output file.
Upvotes: 2