I'm trying to record a jpeg image sent by an Ethernet camera in a mjpg stream. The image I obtain with my Borland C++ application (VSPCIP) looks identical in Notepad++ to the tcp stream saved from the application Wireshark (except for the number of characters : 15540 in my file, and 15342 in the wireshark file, whereas the jpeg content-length is announced to be 15342). That is to say that I have 198 non-displayable characters more than expected but both files have 247 lines.
Here are the two files : http://demo.ovh.com/fr/a61295d39f963998ba1244da2f55a27d/
Which tool could I use (in Notepad++ (I tried to display in UTF8 or ANSI : files still match whereas they don't have the same number of characters) or another editor) to view the non-displayable characters ?
std::ofstream
by default opens the file in text mode, which means it might translate newline characters ('\n'
binary 0x0a) into a carriage-return/newline sequence ("\r\n"
, binary 0x0d and 0x0a).
Open the output file in binary mode and it will most likely solve your problem:
std::ofstream os("filename", ios_base::out | ios_base::binary);