std::mbstowcs function is what you are looking for:
char text = "something"; wchar_t wtext; mbstowcs(wtext, text, strlen(text)+1);//Plus null LPWSTR ptr = wtext;
string text = "something"; wchar_t wtext; mbstowcs(wtext, text.c_str(), text.length());//includes null LPWSTR ptr = wtext;
–> ED: The “L” prefix only works on string literals, not variables. <–
- Easiest way to convert int to string in C++
- How to convert a std::string to const char* or char*
- Static constant string (class member)
- std::string length() and size() member functions
- Convert a String In C++ To Upper Case
- Remove spaces from std::string in C++
- Why is conversion from string constant to ‘char*’ valid in C but invalid in C++
- How do I read an entire file into a std::string in C++?
- Replace part of a string with another string
- How to append a char to a std::string?
- C++ Convert string (or char*) to wstring (or wchar_t*)
- Converting an int to std::string
- How do you reverse a string in place in C or C++?
- Meaning of acronym SSO in the context of std::string
- How to change string into QString?
- How do I concatenate multiple C++ strings on one line?
- C++ deprecated conversion from string constant to ‘char*’
- Is there a simple way to convert C++ enum to string?
- How to convert a number to string and vice versa in C++
- What are the mechanics of short string optimization in libc++?
- Convert float to string with precision & number of decimal digits specified?
- What is the lifetime of the result of std::string::c_str()?
- Sorting Characters Of A C++ String
- Right way to split an std::string into a vector
- How can I extract the file name and extension from a path in C++
- Case insensitive std::string.find()
- Why am I getting string does not name a type Error?
- How to copy std::string into std::vector? [duplicate]
- BSTR to std::string (std::wstring) and vice versa
- What is the type of string literals in C and C++?
- C++ Remove new line from multiline string
- reading a line from ifstream into a string variable
- std::string vs string in c++ [duplicate]
- How to reverse an std::string? [duplicate]
- Difference between string.empty and string == ‘\0’
- Difference between and ?
- When did C++ compilers start considering more than two hex digits in string literal character escapes?
- Deprecated conversion from string literal to ‘char*’ [duplicate]
- How to properly free a std::string from memory
- C++ string to double conversion
- std::stringstream vs std::string for concatenating many strings
- how to check string start in C++
- variable or field declared void
- Using getline() in C++
- Converting a C-style string to a C++ std::string
- Returning an empty string : efficient way in c++
- How can I create a string from a single character?
- C++: is string.empty() always equivalent to string == “”?
- Efficient way to check if std::string has only spaces
- How can I make the map::find operation case insensitive?