Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous message
steveo is currently offline  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

 
Read Message
Read Message
Previous Topic: How to Mask Input fields
Next Topic: The Mysterious checkbox
Goto Forum:
  


Current Time: Sun Apr 28 21:52:59 CEST 2024

Total time taken to generate the page: 0.05502 seconds