std::ostringstream curBuf(std::ios::binary);
curBuf.write((char*)HEAD_DATA,sizeof(HEAD_DATA));
这是一段png加密代码中的一小部分,HEAD_DATA被定义为常量(unsigned char[])类型,储存png头的信息。然而我将curBuf转存值文件后,发现其中多了1个bit"0x0d",十分诡异。然而直接输出至ofstream就不会有这个问题。
黄舟2017-04-17 13:26:58
0x0d character encoding is carriage return
write is an unformatted input and output, carriage return is not omitted
Direct output to ofstream is a formatted input and output, carriage return is omitted