lpcwstr

String to LPCWSTR in c++

ε祈祈猫儿з 提交于 2019-12-22 06:04:05
问题 I'm trying to convert from string to LPCWSTR (I use multi-bite). 1) For example: LPCWSTR ToLPCWSTR(string text) { LPCWSTR sw = (LPCWSTR)text.c_str(); return sw; } 2) This returns Chinese characters: LPCWSTR ToLPCWSTR(string text) { std::wstring stemp = std::wstring(text.begin(), text.end()); LPCWSTR sw = (LPCWSTR)stemp.c_str(); return sw; } However, they both always shows squares: Image EDITED: My code with an edit by: Barmak Shemirani std::wstring get_utf16(const std::string &str, int

String to LPCWSTR in c++

三世轮回 提交于 2019-12-22 06:03:05
问题 I'm trying to convert from string to LPCWSTR (I use multi-bite). 1) For example: LPCWSTR ToLPCWSTR(string text) { LPCWSTR sw = (LPCWSTR)text.c_str(); return sw; } 2) This returns Chinese characters: LPCWSTR ToLPCWSTR(string text) { std::wstring stemp = std::wstring(text.begin(), text.end()); LPCWSTR sw = (LPCWSTR)stemp.c_str(); return sw; } However, they both always shows squares: Image EDITED: My code with an edit by: Barmak Shemirani std::wstring get_utf16(const std::string &str, int

MessageBoxW cannot convert

 ̄綄美尐妖づ 提交于 2019-12-13 07:07:06
问题 I am using wxWidgets 2.9.4 in Visual Studio 2012 and I keep getting these two error messages: Error 1 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char *' to 'LPCWSTR' IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" My code is: #ifdef _WIN32 std::string msg; StringFromFormatV(&msg, format, args); retval = IDYES == MessageBox(0, msg.c_str(), "ERROR! Continue?", MB_ICONQUESTION | MB_YESNO); 回答1: You are compiling your project

Cannot convert parameter 2 from 'const char [14]' to 'LPCWSTR'

对着背影说爱祢 提交于 2019-12-12 12:36:04
问题 I am getting this error: cannot convert parameter 2 from 'const char [14]' to 'LPCWSTR' With the code below. It is supposed to be C but at best visual studio 2012 offers an empty c++ project: #include "windows.h" int WINAPI WinMain (HINSTANCE hinst, HINSTANCE hprevinst, LPSTR cmdline, int showcmd) { MessageBox(NULL, "Merhaba Dunya", "Merhaba", MB_OK); return 0; } What is incorrect? 回答1: It seems your current settings are set up so that WinAPI functions expect wide strings: MessageBox(NULL, L

store a variable that holds user input data in sapi5 speak function

谁说胖子不能爱 提交于 2019-12-11 08:34:35
问题 I am developing an application that uses the Microsoft SAPI5 speech engine. However, I have hit a wall. I've been trying to use the data from the variable that stores the input from the user so the TTS engine can repeat it. But the sapi5 speech function does not allow strings, wstrings or other types except from LPCWSTR which from my research is a pointer to a wide character string, so shouldn't it accept wstrings? Here's some example code from msdn : #include <stdafx.h> #include <sapi.h> int

String to LPCWSTR in c++

﹥>﹥吖頭↗ 提交于 2019-12-05 09:17:40
I'm trying to convert from string to LPCWSTR (I use multi-bite). 1) For example: LPCWSTR ToLPCWSTR(string text) { LPCWSTR sw = (LPCWSTR)text.c_str(); return sw; } 2) This returns Chinese characters: LPCWSTR ToLPCWSTR(string text) { std::wstring stemp = std::wstring(text.begin(), text.end()); LPCWSTR sw = (LPCWSTR)stemp.c_str(); return sw; } However, they both always shows squares: Image EDITED: My code with an edit by: Barmak Shemirani std::wstring get_utf16(const std::string &str, int codepage) { if (str.empty()) return std::wstring(); int sz = MultiByteToWideChar(codepage, 0, &str[0], (int

Corrupted vector entries with LPCWSTR vector

余生长醉 提交于 2019-12-02 18:11:49
问题 I ahve the following piece of code. I get a correctly filled vector. But I am unable to print or use the vector contents which are file names from a directory. As soon as I do enter the first iteration. Everything gets lost. What am I doing wrong? wprintf - This works OK wcout-- here is where everything ends up corrupted #include <windows.h> #include <sstream> #include <string> #include <vector> #include<iostream> void GetAllFiles(vector<LPCWSTR>&, wstring); using namespace std; void main

Corrupted vector entries with LPCWSTR vector

☆樱花仙子☆ 提交于 2019-12-02 07:34:28
I ahve the following piece of code. I get a correctly filled vector. But I am unable to print or use the vector contents which are file names from a directory. As soon as I do enter the first iteration. Everything gets lost. What am I doing wrong? wprintf - This works OK wcout-- here is where everything ends up corrupted #include <windows.h> #include <sstream> #include <string> #include <vector> #include<iostream> void GetAllFiles(vector<LPCWSTR>&, wstring); using namespace std; void main (void) { vector<LPCWSTR> files(0); wstring path = L"Datasets\\Persons\\"; wstring ext = L"*.*"; wstring

C++ lpcwstr to wstring

爱⌒轻易说出口 提交于 2019-12-01 10:52:46
问题 I would like to convert a LPCWSTR to wstring in C++ (VS 2010). I want to use this in OutputDebugStringW(). Thank you. 回答1: Well just pass the LPCWSTR to the constructor of wstring like this: LPCWSTR str=L"fun"; wstring str2(str); 来源: https://stackoverflow.com/questions/15743838/c-lpcwstr-to-wstring

Cast (const) char * to LPCWSTR [duplicate]

守給你的承諾、 提交于 2019-11-30 09:24:26
问题 This question already has answers here : How do I convert a char string to a wchar_t string? (4 answers) Closed 5 years ago . I'm trying to use FindWindow() from WinAPI, and I want to ask an input for window's title from the user: char *input; cout << "Window title: "; cin >> input; Pretty standard. Now then, how do I convert this to LPCWSTR for FindWindow() ? I've already tried the following: _T(input) , TEXT(input) , (LPCWSTR)input but none of them worked. I also tried using wchar_t instead