How to convert string to wchar_t in C++

1 Answer

0 votes
#include <iostream>
#include <codecvt>
#include <string>
#include <locale> 

int main() {
    std::string str = "C++ Programming";

    std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
    
    std::wstring ws = converter.from_bytes(str);
    
    std::wcout << ws;
}


/*
run:

C++ Programming

*/

 



answered Oct 10, 2024 by avibootz

Related questions

1 answer 93 views
1 answer 134 views
134 views asked Aug 15, 2022 by avibootz
1 answer 101 views
1 answer 123 views
1 answer 150 views
150 views asked Feb 11, 2023 by avibootz
3 answers 179 views
179 views asked Apr 7, 2022 by avibootz
...