0

Beginner c++ developer, here. I'm writing a program Under Windows10 with Character set = Use Unicode Character Set in the properties tab.

I'm trying to use an API to returns a _UNICODE_STRING (winternl.h). I need to convert it to a std::string, and after having spent a lot of time, don't find my way around. All I found here is this question, which doesn't seems to help, since it targets a very specific context.

Of course I realize there are a lot of things I should learn before becoming comfortable with strings in C++ (I come from C#), and I have selected a few articles for further reading, but I was hoping I could use this day to move forward with the program I'm trying to write.

So, is there a way to perform the needed conversion? Sorry if the answer is obvious, thanks a million if you can help!

Eric P.
  • 97
  • 1
  • 7
  • Thank you for the link. I haven't read it all yet, but I can see at the beginning:The problem is that neither char nor wchar_t is directly tied to unicode. Not much is said about conversion, and if I try to cast the _UNICODE_STRING to wstring, I get : no suitable user-defined conversion from "_UNICODE_STRING" to "std::wstring" exists. So...are you sure it's a duplicate? Doesn't seems obvious – Eric P. Jun 03 '18 at 12:49
  • Wait, I think I found something... – Eric P. Jun 03 '18 at 12:57
  • paercebal's answer explains throughly how to deal with wide chars on Windows, including how to perform conversion – user7860670 Jun 03 '18 at 13:50
  • Indeed..got it! Thanks – Eric P. Jun 03 '18 at 16:48

0 Answers0