This conversion is not performed (usually) with stream, streambuf or facet. It is responsible for the C library code (for example, fputc()) that is called by streambuf overflow()and underflow().
If you need this for any reason (for example, when implementing the dos2unix procedure), there is a convenient example in boost.iostreams.
EDIT: std::filebufonly supports multibyte encodings for text files such as UTF-8 or GB18030, or whatever language it uses. A UTF-16 file should be opened in binary mode, as a simple stream of bytes (which can be interpreted as UTF-16 with C ++ 11 codecvt tools), and yes, line endings will not be converted.
Cubbi source
share