Search
 
SCRIPT & CODE EXAMPLE
 

CPP

how to convert string to wchar_t in c++

std::wstring s2ws(const std::string& s)
{
    int len;
    int slength = (int)s.length() + 1;
    len = MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, 0, 0);
    wchar_t* buf = new wchar_t[len];
    MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, buf, len);
    std::wstring r(buf);
    delete[] buf;
    return r;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ loop through array backwards 
Cpp :: how to hide the console c++ 
Cpp :: how to downgrade numpy 
Cpp :: git branch in my bash prompt 
Cpp :: c++ addition 
Cpp :: 3d dynamic array c++ 
Cpp :: c++ primality test 
Cpp :: qchar to char 
Cpp :: arduino for command 
Cpp :: how to print in c++ 
Cpp :: flake8 max line length 
Cpp :: sleep in cpp 
Cpp :: for vector c++ 
Cpp :: C++ red text output 
Cpp :: c++ check if string contains substring 
Cpp :: eosio multi index clear 
Cpp :: find all occurrences of a substring in a string c++ 
Cpp :: hide terminal window c++ 
Cpp :: how to sort a 2d array in c++ 
Cpp :: pairs 
Cpp :: ostream was not declared in this scope 
Cpp :: how to sort a string in c++ 
Cpp :: c++ read file to char buffer 
Cpp :: remove value from vector c++ 
Cpp :: how to print text on C++ 
Cpp :: Write C++ program to copy one string to another string using pointers 
Cpp :: cpp take lambda as parameter 
Cpp :: create a dictionary cpp 
Cpp :: sort function from bigest to smallest c++ 
Cpp :: how to traverse a linked list in c++ 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =