I try to read one text file as binary and then render it in console-app.
I’ve got the next result: http://pastebin.com/gubYpAVZ
I’m questioning: “Why I have got such symbols, that I don’t have in the text file?” , if I open it in notepad – I shall see only “Hello World!” and no more… What are other symbols???
Here is code:
ifstream in("C:\\dev\\1.txt", ios::in | ios::binary);
list<int> mylist1;
list<int>::iterator it;
while(!in.eof())
{
mylist1.push_back(in.get());
};
for(it = mylist1.begin(); it != mylist1.end(); it++)
{
cout << *it << " -> " << (char)*it << endl;
};
in.close();
Best Regards,
One possibility might be that the file contains Unicode characters, which might have multiple bytes per character. And some of those character values at the beginning look like they are part of a BOM (byte order mark). In particular, 239, 187, 191 (0xef, 0xbb, 0xbf) seem to indicate some UTF-8 data.