wstring

Convert CString to std::wstring

给你一囗甜甜゛ 提交于 2019-12-18 18:55:35
问题 How can I convert from CString to std::wstring ? 回答1: To convert CString to std::wstring : CString hi("Hi"); std::wstring hi2(hi); And to go the other way, use c_str() : std::wstring hi(L"Hi"); CString hi2(hi.c_str()); 回答2: Try this: std::wstring strString((LPCTSTR)strCString); 回答3: This should work as CString has operator LPCTSTR() defined: CString s; std::wstring s1 = s; 回答4: CString s = _T("Привет"); USES_CONVERSION; std::wstring ws(A2W((LPCTSTR)s)); 来源: https://stackoverflow.com/questions

Convert CString to std::wstring

走远了吗. 提交于 2019-12-18 18:55:35
问题 How can I convert from CString to std::wstring ? 回答1: To convert CString to std::wstring : CString hi("Hi"); std::wstring hi2(hi); And to go the other way, use c_str() : std::wstring hi(L"Hi"); CString hi2(hi.c_str()); 回答2: Try this: std::wstring strString((LPCTSTR)strCString); 回答3: This should work as CString has operator LPCTSTR() defined: CString s; std::wstring s1 = s; 回答4: CString s = _T("Привет"); USES_CONVERSION; std::wstring ws(A2W((LPCTSTR)s)); 来源: https://stackoverflow.com/questions

What's “wrong” with C++ wchar_t and wstrings? What are some alternatives to wide characters?

筅森魡賤 提交于 2019-12-17 01:41:46
问题 I have seen a lot of people in the C++ community(particularly ##c++ on freenode) resent the use of wstrings and wchar_t , and their use in the windows api. What is exactly "wrong" with wchar_t and wstring , and if I want to support internationalization, what are some alternatives to wide characters? 回答1: What is wchar_t? wchar_t is defined such that any locale's char encoding can be converted to a wchar_t representation where every wchar_t represents exactly one codepoint: Type wchar_t is a

How to convert wstring into string?

送分小仙女□ 提交于 2019-12-16 20:03:41
问题 The question is how to convert wstring to string? I have next example : #include <string> #include <iostream> int main() { std::wstring ws = L"Hello"; std::string s( ws.begin(), ws.end() ); //std::cout <<"std::string = "<<s<<std::endl; std::wcout<<"std::wstring = "<<ws<<std::endl; std::cout <<"std::string = "<<s<<std::endl; } the output with commented out line is : std::string = Hello std::wstring = Hello std::string = Hello but without is only : std::wstring = Hello Is anything wrong in the

Bad pointer or link issue when creating wstring from vc6 dll

Deadly 提交于 2019-12-14 03:08:39
问题 I got a DLL generated on VC6 and using wstring , and I'm trying to use it in a VC9 project. In this DLL there is a higher level class manipulating wstring , called UtfString . I got everything imported correctly in my project, but when I call: std::wstring test; UtfString uTest(test); it won't link, even if the function prototype is in the lib... The other issuer is that when create a new UtfString, and debug my app, the new pointer is <Bad Ptr> . I suspect a conflict between VC6 wstring and

Convert from Wstring to CComBstr

徘徊边缘 提交于 2019-12-13 07:09:44
问题 Please suggest me methods for converting from wstring to CComBstr. I tried to convert like following but it is failing CComBSTR BstrAddress(strID); // strID is wstring type I am getting error as "cannot convert parameter 1 from 'std::wstring' to 'int'" Please help me regarding this 回答1: These are constructors of CComBSTR class: CComBSTR( ) throw( ); CComBSTR( const CComBSTR& src ); CComBSTR( REFGUID guid ); CComBSTR( int nSize ); CComBSTR( int nSize, LPCOLESTR sz ); CComBSTR( int nSize,

Conversion from char * to wchar* does not work properly

喜夏-厌秋 提交于 2019-12-13 05:53:07
问题 I'm getting a string like: "aña!a¡a¿a?a" from the server so I decode it and then I pass it to a function. What I need to do with the message is something like loading paths depending the letters. The header of my function is: void SetInfo(int num, char *descr[4]) so it receives one number and an array of 4 chars (sentences). To make it easier, let's say I just need to work only with descr[0]. When I debug and arrive there to SetInfo(), I get the exact message in the debugg view: "aña!a¡a¿a?a"

Call a wstring C++ method from C#

感情迁移 提交于 2019-12-13 04:00:23
问题 I am using C# code and need to call this method inside a C++ dll. static std::wstring DecryptData(const std::wstring& strKey); I've read many things and my best guess would be to pass something that is easier to read for both languages, like char-array or even byte-array and build the wstring in C++ and the string in C# afterwards. Did anyone do that already? Edit: I read the linkes Topic but none of the answers helps me: Using const didn't help. This is what I have now: C# [DllImport(DLL

wstring -> LPCWSTR in ShellExecute give me error LNK2028 & LNK2019

我的梦境 提交于 2019-12-13 00:37:02
问题 Hello I'm programming in Visual C++ 2010 (spanish) with UNICODE and /clr. I have a header file called "fileFuncs.h": #include <iostream> #include <fstream> #include <string> #include <stdlib.h> #include <string> using namespace std; 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)

Ctypes wstring pass by reference

可紊 提交于 2019-12-11 22:25:41
问题 How can I create a unicode buffer in python, pass by ref to a C++ function and get the wstring back and use it in python ? c++ code: extern "C" { void helloWorld(wstring &buffer) { buffer = L"Hello world"; } } python code: import os import json from ctypes import * lib = cdll.LoadLibrary('./libfoo.so') lib.helloWorld.argtypes = [pointer(c_wchar_p)] buf = create_unicode_buffer("") lib.helloWorld(byref(buf)) str = cast(buf, c_wchar_p).value print(str) I get this error: lib.helloWorld.argtypes =