Home » Community » Newbie corner » Reliably converting between std::vector<uint8_t> and WString (I would like to use other libraries which leverage std::vector etc and would like to know how to convert)
Reliably converting between std::vector<uint8_t> and WString [message #55560] |
Sun, 22 November 2020 00:17  |
steveo
Messages: 11 Registered: November 2020
|
Promising Member |
|
|
I have a desire to use some encryption libraries which are not WString aware.
How do I reliably take the raw buffer of a WString and convert it to a std::vector<uint8_t>?
and conversely.
How do I reliably take a buffer thus converted and reliably put it back into a WString?
It's been years since I did pointer arithmetic and back in the day we simply ignored WString because we could.
WString input = "Some unicode text";
std::vector<uint8_t> bytes(const uint8_t*)input.Begin(), input.GetCount()*sizeof(wchar));
WString output((const wchar*)bytes.data(), (bytes.size()/sizeof(wchar));
[Updated on: Sun, 22 November 2020 00:24] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Fri Apr 25 12:44:44 CEST 2025
Total time taken to generate the page: 0.03572 seconds
|