I have the following code in ANSII:
boost::asio::streambuf buffer;
std::ostream oss(&buffer);
boost::asio::async_write(socket_, buffer,
strand_.wrap(
boost::bind(&Connection::handleWrite, shared_from_this(),
boost::asio::placeholders::error)));
I need to convert it to UNICODE. I tried the following:
boost::asio::basic_streambuf<std::allocator<wchar_t>> buffer;
std::wostream oss(&buffer);
boost::asio::async_write(socket_, buffer,
strand_.wrap(
boost::bind(&Connection::handleWrite, shared_from_this(),
boost::asio::placeholders::error)));
Is there a way to use async_write() in UNICODE?
You need to know what encoding your data is coming in as.
For example in my applications I know the unicode data is coming in as UTF-8, and so I use the normal
charversions of the functions. I then need to treat the buffers as unicode utf-8 data – but everything is received / sent OK.If you’re using a different character encoding then you may (or may not) get better milage using a wide character version like you have tried.