skipws flag set when opening an input file stream in binary mode

前端 未结 1 760
星月不相逢
星月不相逢 2021-01-19 11:04

I know the extraction operator should not be used on an input stream opened in binary mode, but the member function read should be used instead.



        
1条回答
  •  执笔经年
    2021-01-19 11:59

    "Binary" mode, as controlled by std::ios_base::binary is only for switching off the translation of newlines between the standard C++ \n character and the system specific newline sequence as stored in files.

    It's completely independent of whether you are parsing a file that contains meaningful separating whitespace or some completely different byte format so there's no reason to tie the two orthogonal pieces of functionality together.

    (The C++ standard doesn't say much about what binary mode means, there is more detail in the C standard which talks about the potential differences between text streams and binary streams. Binary streams must read back byte for byte as they were written on any given system whereas text stream need only do so given a number of restrictions centring around not having extra spaces before a newline and not having any control characters other than newlines and tabs. A system need not make any distinction at all between binary and text streams.)

    0 讨论(0)
提交回复
热议问题