Subject: [Boost-bugs] [Boost C++ Libraries] #9297: "boost::iostreams::file_descriptor_sink" doesn't support translation of line endings on Windows
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-10-24 09:33:20
#9297: "boost::iostreams::file_descriptor_sink" doesn't support translation of
line endings on Windows
----------------------------------+-----------------------
Reporter: m.kosch@⦠| Owner: turkanis
Type: Bugs | Status: new
Milestone: To Be Determined | Component: iostreams
Version: Boost 1.54.0 | Severity: Problem
Keywords: file_descriptor_sink |
----------------------------------+-----------------------
When a Windows file descriptor is opened in text mode, all newline
characters written to this file are translated to CRLF. However, if
''boost::iostreams::file_descriptor_sink'' is used on such a file
descriptor to write newlines to a stream, these newline characters are not
translated to CRLF.
The following sample program demonstrates this:
{{{#!c++
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/stream.hpp>
#include <fcntl.h>
#include <io.h>
#include <string>
#include <sys/stat.h>
int main()
{
static const std::string str1 = "This is a line";
static const std::string str2 = "This is another line";
int fd = _open("output.txt", _O_WRONLY | _O_CREAT | _O_TRUNC |
_O_TEXT,
_S_IREAD | _S_IWRITE);
_write(fd, str1.data(), str1.size());
_write(fd, "\n", 1); // This writes "\r\n"
boost::iostreams::file_descriptor_sink sink(fd,
boost::iostreams::close_handle);
boost::iostreams::stream<boost::iostreams::file_descriptor_sink>
stream(sink);
stream << str2;
stream << std::endl; // This only writes "\n"
return 0;
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9297> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:14 UTC