I have a 3rd party device that communicates with my Linux box over a proprietary communication protocol that isn't well documented. Some packets convey "strings" that, after reading this Joel On Software article, appears to be in UTF16 Little-Endian encoding. In other words, what I have on my Linux box after receipt of such packets are things like
// The string "Out"
unsigned char data1[] = {0x4f, 0x00, 0x75, 0x00, 0x74, 0x00, 0x00, 0x00};
// The string "°F"
unsigned char data2[] = {0xb0, 0x00, 0x46, 0x00, 0x00, 0x00};
As I understand it, I cannot treat these as an std::wstring because on Linux a wchar_t is 4 bytes. I do, however, have one thing going for me in that my Linux box is also Little-Endian. So, I believe I need to use something like std::codecvt_utf8_utf16<char16_t>. However, even after reading the documentation, I cannot figure out how to actually go from an unsigned char[] to an std::string. Can someone please help?