char data_[4096];
...
socket_.async_read_some(boost::asio::buffer(data_, 4096),
boost::bind(&client::handle_read_header, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
when function handle_read_header is fired, data_ contains many \0 symbols in text.
with help of which way is it easier to view full (with stripped or escaped \0) string by std::cout? (by default \0 make end of string and don’t show other)
Seth kindly pointed out your requirement to make it “easier to view”. For that:
The above uses 3-digit back-slash escaped octal notation to represent non-printable characters. You can change the representation easily enough.
(For a simple binary write, you can call
std::cout.write(buffer, num_bytes)to do a binary block write, rather thanstd::cout << bufferwhich relies on the ASCIIZ convention for character arrays/pointers. Then you could pipe the result intoless,cat -vtor whatever your OS provides that helps view binary data including NULs.)