When reading a binary .img why is it when you read it by slurping in the file, then save it to a string and cout, you don't see the binary but random garbage?
When reading a binary .img why is it when you read it by slurping in the file, then save it to a string and cout, you don't see the binary but random garbage?
Probably because you're reading random garbage.
How are you trying to read the file? Show your code.
Jim
O_o
How do you know you aren't seeing the binary?
A text file is binary, but a binary file need not be text.
Soma
“Salem Was Wrong!” -- Pedant Necromancer
“Four isn't random!” -- Gibbering Mouther
What did you expect to see as output? Keep in mind post #3.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Look at what you wrote:Originally Posted by c_weed
You used std::istreambuf_iterator to read bytes from the input stream into a std::string, then you printed the std::string. You're operating on the level of bytes, not bits. You are getting 1s and 0s, but they are in groups, presumably of 8, and interpreted in a group as a character.Code:string content( (std::istreambuf_iterator<char>(ifs) ), (std::istreambuf_iterator<char>() ) ); cout << content << endl;
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
It will depend on what you are looking at it with, I would imagine. If you look at it with as text, you will see whatever the bits corresponding characters are in ANSI or UNICODE or whatever. If you look at it with a hex editor, you most likely see hexadecimal, which you could use to pick out specific things if you know the format of the data. It is all still the same data on the binary level.
WndProc = (2[b] || !(2[b])) ? SufferNobly : TakeArms;
You need to learn the fundamentals ASCII, UNICODE, character sets. Binary ASCII is encoded according to the ASCII character set from 0-255, ASCII - Wikipedia, the free encyclopedia
ASCII is an encoding, basically an interpretation of bits. It is defined through 0 - 127. The 7th bit is not defined in ASCII at all, but there are many "extended" ASCII sets in which the 7th bit is used to encode more symbols. These different "ASCII sets" are typically called locales and are the root of much evil™ (because the same bits mean different things in different locales!).
I don't understand what you mean? I know a text editor will interpret the value according to the code page it is using (with most mapping the original 7 bits to the normal ASCII characters, and the upper bit mapping to diacritics or whatever wants to be there). How does this modify that a text editor would interpret the values to be whatever characters they map to?
WndProc = (2[b] || !(2[b])) ? SufferNobly : TakeArms;