Hello guys im searching for method to convert a std::string 2 a lpcwstr
google just refers me in a circle hope someone of you can give a correct clear anwser Error say : no suitable constructor exists to convert from "const char*" to std::basic_string....
Just convert your std::string to an std::wstring and provide the method you're about to call with .c_str(). However, that error is a bit odd for what you're trying, so if you got problems you'd best include the code causing them.
Code:
#include <string>
...
std::string x("This is my string.");
std::wstring y;
for (char c : x) y.push_back(c);
ImportantMethodTakingLPCWSTR(y.c_str());
...
There are other ways, but this is pretty straightforward I suppose. You could also manage the memory of the LPCWSTR yourself instead of letting this do std::wstring. As you're a beginner as it seems I wouldn't recommend it though.
With best regards
Jeoni
Hey. First of all std::string is a class which is meant for easier handling of a string.
This means there is no conversion to a built-in type.
The cleanest method is described above by Terreox. It's always a good practice too use the STL.
A more low-level attempt would be to use MultiByteToWideChar or a function implemented in CRT, mbstowcs to convert a given character-sequence from utf8 to utf16 (unicode) and then construct a string object.
[C#] String ersetzen in grossem string 10/09/2015 - .NET Languages - 0 Replies Moin alle zusammen
Ich schreibe im Moment eine kleine WPF Applikation um das Updaten von Kundenprojekt in unserer Firma zu vereinfachen. Dazu habe ich eine Liste von SQL-Skripts welche ausgeführt werden müssen. Ich lesen den Inhalt des Skripts in eine string variable. Diese Skripts enthalten jeweils eine Zeile 'USE '. Nun muss ich das 'KORREKTE_DATENBANK_EINTRAGEN' durch den DB Namen ersetzen.
Folgenden Code habe ich probiert aber es scheint nichts zu ändern:
string content =...
LPCWSTR Konvertierung 04/06/2014 - C/C++ - 4 Replies Moin,
char space;
>> Konvertierung des Parameters 2 von 'char ' in 'LPCWSTR' nicht möglich
Der zweite Parameter ist der space:
pFont->DrawText(NULL, space, );
Hat dafür wer eine Lösung?
[VB08]String in String mit mehreren Funden 08/08/2011 - .NET Languages - 6 Replies Hey,
bin gerade auf ein Problem gestoßen, an dem ich mir seit 3 Stunden die Zähne ausbeiße.
Ich will eine Funktion schreiben, die der _StringBetween Funktion von AutoIt gleich ist. _StringBetween gibt in einem Array alle Strings zwischen zwei SubStrings und dem ganzen String aus. Die Ausgabe bei
_StringBetween("<h1>test1</h1>&l t;h1>test2</h1>", "<h1>", "</h1>") wäre also idealer Weiße ein Array (x = "test1", x = "test2")...
da man in VB08 kein Array returnen kann, komme ich aber einfach...