Answer the question
In order to leave comments, you need to log in
How to implement converting unicode string to utf-8 C++?
Hello! There is a project on VS 2005, going to unicode.
Here's a snippet of code:
string LDAP="LDAP://";
string path = LDAP + strDesc;
wstring wstr( path.begin(), path.end() );
LPCTSTR path2 = W2CT( wstr.c_str( ) );
hr = ADsGetObject( path2, IID_IADs,(void**)&pUsr);
Answer the question
In order to leave comments, you need to log in
You can take utfcpp , just use:
std::wstring ws;
utf8::utf8to16( str.begin(), str.end(), std::back_inserter(ws) );
std::string str;
utf8::utf16to8( ws.begin(), ws.end(), std::back_inserter(str) );
In general, I decided to look at the character codes in the line, brought them to the file, I got this:
76
68
65
80
58
47
47
67
78
61
-34
-16
-24
-23
32
-49
-27
-14
-16
-18
-30
44
67
78
61
85
115
101
114
115
44
68
67
61
118
105
112
44
68
67
61
99
98
114
0
string strDesc = static_cast<CHAR*>(CW2A(bstr));//
string LDAP="LDAP://"; //
string path = LDAP + strDesc;
wstring wstr( path.begin(), path.end() ); //
LPCTSTR path2 = W2CT( wstr.c_str( ) );
LPSTR path3 = const_cast<char *>(path.c_str());
LPWSTR result;
MultiByteToWideChar(CP_UTF8,0,path3,strlen(path3)+1,result, strlen(path3)+1);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question