VSVS程序错误RC1110C++:不存在从 "WCHAR [260]" 转换到 "std::basic_string<char," 的适当构造函数

欢迎加入我们,一同切磋技术 &
用户名: &&&
密 码: &
共有 6544 人关注过本帖
标题:vs2010 开发遇到的一个问题,请教高手
等 级:新手上路
结帖率:50%
&&已结贴√
&&问题点数:20&&回复次数:3&&&
vs2010 开发遇到的一个问题,请教高手
用VS2010开发一个程序。
加入头文件和LIB库,编译后出现了很多错误,不知道怎么回事?
ua client.obj : error LNK2028: 无法解析的标记(0A0003BA) &void * __cdecl operator new[](unsigned int)& (??_U@$$FYAPAXI@Z),该标记在函数 &public: void __thiscall UaObjectArray&class UaClientSdk::DeleteRawModifiedDetail&::create(unsigned long)& (?create@?$UaObjectArray@VDeleteRawModifiedDetail@UaClientSdk@@@@$$FQAEXK@Z) 中被引用
1&ua client.obj : error LNK2028: 无法解析的标记(0A000410) &void __cdecl std::_Debug_message(wchar_t const *,wchar_t const *,unsigned int)& (?_Debug_message@std@@$$FYAXPB_W0I@Z),该标记在函数 &public: void __thiscall std::_Iterator_base12::_Orphan_me(void)& (?_Orphan_me@_Iterator_base12@std@@$$FQAEXXZ) 中被引用
1&MSVCMRTD.lib(locale0_implib.obj) : error LNK2028: 无法解析的标记(0A0003C3) &void __cdecl std::_Debug_message(wchar_t const *,wchar_t const *,unsigned int)& (?_Debug_message@std@@$$FYAXPB_W0I@Z),该标记在函数 &public: void __thiscall std::_Iterator_base12::_Orphan_me(void)& (?_Orphan_me@_Iterator_base12@std@@$$FQAEXXZ) 中被引用
1&ua client.obj : error LNK2028: 无法解析的标记(0A000412) &public: __thiscall std::_Lockit::_Lockit(int)& (??0_Lockit@std@@$$FQAE@H@Z),该标记在函数 &public: void __thiscall std::_Iterator_base12::_Adopt(struct std::_Container_base12 const *)& (?_Adopt@_Iterator_base12@std@@$$FQAEXPBU_Container_base12@2@@Z) 中被引用
1&MSVCMRTD.lib(locale0_implib.obj) : error LNK2028: 无法解析的标记(0A000355) &public: __thiscall std::_Lockit::_Lockit(int)& (??0_Lockit@std@@$$FQAE@H@Z),该标记在函数 &public: __thiscall std::_Iterator_base12::~_Iterator_base12(void)& (??1_Iterator_base12@std@@$$FQAE@XZ) 中被引用
1&ua client.obj : error LNK2028: 无法解析的标记(0A00049F) &void __cdecl __ExceptionPtrCopy(void *,void const *)& (?__ExceptionPtrCopy@@$$FYAXPAXPBX@Z),该标记在函数 &public: __thiscall std::_Exception_ptr::_Exception_ptr(class std::_Exception_ptr const &)& (??0_Exception_ptr@std@@$$FQAE@ABV01@@Z) 中被引用
1&MSVCMRTD.lib(locale0_implib.obj) : error LNK2028: 无法解析的标记(0A00032B) &void __cdecl __ExceptionPtrCopy(void *,void const *)& (?__ExceptionPtrCopy@@$$FYAXPAXPBX@Z),该标记在函数 &public: __thiscall std::_Exception_ptr::_Exception_ptr(class std::_Exception_ptr const &)& (??0_Exception_ptr@std@@$$FQAE@ABV01@@Z) 中被引用
1&ua client.obj : error LNK2028: 无法解析的标记(0A0004A6) &extern &C& void __cdecl _wassert(wchar_t const *,wchar_t const *,unsigned int)& (?_wassert@@$$J0YAXPB_W0I@Z),该标记在函数 &public: unsigned char & __thiscall UaStackTypeArray&unsigned char,&void __cdecl ClearNothing(void *)&::operator[](unsigned long)const & (??A?$UaStackTypeArray@E$1?ClearNothing@@$$FYAXPAX@Z@@$$FQBEAAEK@Z) 中被引用
1&ua client.obj : error LNK2028: 无法解析的标记(0A00050E) &void __cdecl operator delete[](void *)& (??_V@$$FYAXPAX@Z),该标记在函数 &public: void * __thiscall UaClientSdk::DeleteRawModifiedDetail::`vector deleting destructor'(unsigned int)& (??_EDeleteRawModifiedDetail@UaClientSdk@@$$FQAEPAXI@Z) 中被引用
1&MSVCMRTD.lib(locale0_implib.obj) : error LNK2028: 无法解析的标记(0A0002DF) &void __cdecl operator delete[](void *)& (??_V@$$FYAXPAX@Z),该标记在函数 &public: virtual void * __thiscall std::runtime_error::`vector deleting destructor'(unsigned int)& (??_Eruntime_error@std@@$$FUAEPAXI@Z) 中被引用
1&MSVCMRTD.lib(mstartup.obj) : error LNK2028: 无法解析的标记(0A000098) &extern &C& void __cdecl __security_init_cookie(void)& (?__security_init_cookie@@$$J0YAXXZ),该标记在函数 &private: void __thiscall &CrtImplementationDetails&::LanguageSupport::InitializeNative(void)& (?InitializeNative@LanguageSupport@&CrtImplementationDetails&@@$$FAAEXXZ) 中被引用
1&MSVCMRTD.lib(mstartup.obj) : error LNK2020: 无法解析的标记(0A00009A) __native_vcclrit_reason
1&MSVCMRTD.lib(mstartup.obj) : error LNK2020: 无法解析的标记(0A0000A2) __native_startup_state
1&MSVCMRTD.lib(mstartup.obj) : error LNK2020: 无法解析的标记(0A00010A) __native_startup_lock
1&MSVCMRTD.lib(mstartup.obj) : error LNK2020: 无法解析的标记(0A00010B) __native_dllmain_reason
1&MSVCMRTD.lib(managdeh.obj) : error LNK2028: 无法解析的标记(0A00003D) &extern &C& int __cdecl __FrameUnwindFilter(struct _EXCEPTION_POINTERS *)& (?__FrameUnwindFilter@@$$J0YAHPAU_EXCEPTION_POINTERS@@@Z),该标记在函数 &extern &C& void __clrcall ___CxxCallUnwindDtor(void (__clrcall*)(void *),void *)& (?___CxxCallUnwindDtor@@$$J0YMXP6MXPAX@Z0@Z) 中被引用
1&MSVCMRTD.lib(locale0_implib.obj) : error LNK2028: 无法解析的标记(0A000075) &public: __thiscall std::_Container_base12::_Container_base12(void)& (??0_Container_base12@std@@$$FQAE@XZ),该标记在函数 &public: __thiscall std::_String_val&wchar_t,class std::allocator&wchar_t& &::_String_val&wchar_t,class std::allocator&wchar_t& &(class std::allocator&wchar_t&)& (??0?$_String_val@_WV?$allocator@_W@std@@@std@@$$FQAE@V?$allocator@_W@1@@Z) 中被引用
1&MSVCMRTD.lib(locale0_implib.obj) : error LNK2028: 无法解析的标记(0A000077) &public: __thiscall std::_Container_base12::~_Container_base12(void)& (??1_Container_base12@std@@$$FQAE@XZ),该标记在函数 &public: __thiscall std::_String_val&wchar_t,class std::allocator&wchar_t& &::_String_val&wchar_t,class std::allocator&wchar_t& &(class std::allocator&wchar_t&)& (??0?$_String_val@_WV?$allocator@_W@std@@@std@@$$FQAE@V?$allocator@_W@1@@Z) 中被引用
1&MSVCMRTD.lib(locale0_implib.obj) : error LNK2028: 无法解析的标记(0A00007F) &public: void __thiscall std::_Container_base12::_Orphan_all(void)& (?_Orphan_all@_Container_base12@std@@$$FQAEXXZ),该标记在函数 &public: __thiscall std::_String_val&wchar_t,class std::allocator&wchar_t& &::~_String_val&wchar_t,class std::allocator&wchar_t& &(void)& (??1?$_String_val@_WV?$allocator@_W@std@@@std@@$$FQAE@XZ) 中被引用
1&MSVCMRTD.lib(locale0_implib.obj) : error LNK2028: 无法解析的标记(0A00029C) &void * __cdecl operator new(unsigned int,struct std::_DebugHeapTag_t const &,char *,int)& (??2@$$FYAPAXIABU_DebugHeapTag_t@std@@PADH@Z),该标记在函数 &private: static void __cdecl std::locale::facet::_Facet_Register_m(class std::locale::facet *)& (?_Facet_Register_m@facet@locale@std@@$$FCAXPAV123@@Z) 中被引用
1&MSVCMRTD.lib(locale0_implib.obj) : error LNK2028: 无法解析的标记(0A0002A5) &extern &C& int __cdecl __CxxQueryExceptionSize(void)& (?__CxxQueryExceptionSize@@$$J0YAHXZ),该标记在函数 &public: void __thiscall std::basic_string&wchar_t,struct std::char_traits&wchar_t&,class std::allocator&wchar_t& &::_Copy(unsigned int,unsigned int)& (?_Copy@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@$$FQAEXII@Z) 中被引用
1&MSVCMRTD.lib(locale0_implib.obj) : error LNK2028: 无法解析的标记(0A0002A7) &extern &C& int __cdecl __CxxDetectRethrow(void *)& (?__CxxDetectRethrow@@$$J0YAHPAX@Z),该标记在函数 __catch$?_Copy@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@$$FQAEXII@Z$0 中被引用
1&MSVCMRTD.lib(locale0_implib.obj) : error LNK2028: 无法解析的标记(0A0002CD) &extern &C& void __cdecl __CxxUnregisterExceptionObject(void *,int)& (?__CxxUnregisterExceptionObject@@$$J0YAXPAXH@Z),该标记在函数 __catch$?_Copy@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@$$FQAEXII@Z$0 中被引用
1&MSVCMRTD.lib(locale0_implib.obj) : error LNK2028: 无法解析的标记(0A0002CF) &void __cdecl operator delete(void *,struct std::_DebugHeapTag_t const &,char *,int)& (??3@$$FYAXPAXABU_DebugHeapTag_t@std@@PADH@Z),该标记在函数 &private: static void __cdecl std::locale::facet::_Facet_Register_m(class std::locale::facet *)& (?_Facet_Register_m@facet@locale@std@@$$FCAXPAV123@@Z) 中被引用
1&MSVCMRTD.lib(locale0_implib.obj) : error LNK2028: 无法解析的标记(0A0002DB) &extern &C& int __cdecl __CxxExceptionFilter(void *,void *,int,void *)& (?__CxxExceptionFilter@@$$J0YAHPAX0H0@Z),该标记在函数 __catch$?_Copy@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@$$FQAEXII@Z$0 中被引用
1&MSVCMRTD.lib(locale0_implib.obj) : error LNK2028: 无法解析的标记(0A000305) &extern &C& int __cdecl __CxxRegisterExceptionObject(void *,void *)& (?__CxxRegisterExceptionObject@@$$J0YAHPAX0@Z),该标记在函数 __catch$?_Copy@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@$$FQAEXII@Z$0 中被引用
1&MSVCMRTD.lib(locale0_implib.obj) : error LNK2028: 无法解析的标记(0A00034C) &void __cdecl std::_Xlength_error(char const *)& (?_Xlength_error@std@@$$FYAXPBD@Z),该标记在函数 &public: void __thiscall std::basic_string&wchar_t,struct std::char_traits&wchar_t&,class std::allocator&wchar_t& &::_Xlen(void)const & (?_Xlen@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@$$FQBEXXZ) 中被引用
1&MSVCMRTD.lib(locale0_implib.obj) : error LNK2028: 无法解析的标记(0A000357) &public: static void __cdecl std::_Lockit::_Lockit_ctor(int)& (?_Lockit_ctor@_Lockit@std@@$$FSAXH@Z),该标记在函数 __catch$?_Fac_tidy@?A0x@@$$FYAXXZ$0 中被引用
1&MSVCMRTD.lib(locale0_implib.obj) : error LNK2028: 无法解析的标记(0A000358) &public: static void __cdecl std::_Lockit::_Lockit_dtor(int)& (?_Lockit_dtor@_Lockit@std@@$$FSAXH@Z),该标记在函数 __catch$?_Fac_tidy@?A0x@@$$FYAXXZ$0 中被引用
1&MSVCMRTD.lib(locale0_implib.obj) : error LNK2028: 无法解析的标记(0A00035F) &void __cdecl std::_Xout_of_range(char const *)& (?_Xout_of_range@std@@$$FYAXPBD@Z),该标记在函数 &public: void __thiscall std::basic_string&wchar_t,struct std::char_traits&wchar_t&,class std::allocator&wchar_t& &::_Xran(void)const & (?_Xran@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@$$FQBEXXZ) 中被引用
1&MSVCMRTD.lib(locale0_implib.obj) : error LNK2028: 无法解析的标记(0A000371) &public: __thiscall std::exception::exception(class std::exception const &)& (??0exception@std@@$$FQAE@ABV01@@Z),该标记在函数 &public: __thiscall std::runtime_error::runtime_error(class std::runtime_error const &)& (??0runtime_error@std@@$$FQAE@ABV01@@Z) 中被引用
1&MSVCMRTD.lib(locale0_implib.obj) : error LNK2028: 无法解析的标记(0A000373) &public: __thiscall std::exception::exception(char const * const &)& (??0exception@std@@$$FQAE@ABQBD@Z),该标记在函数 &public: __thiscall std::bad_alloc::bad_alloc(char const *)& (??0bad_alloc@std@@$$FQAE@PBD@Z) 中被引用
1&MSVCMRTD.lib(locale0_implib.obj) : error LNK2028: 无法解析的标记(0A000374) &public: virtual __thiscall std::exception::~exception(void)& (??1exception@std@@$$FUAE@XZ),该标记在函数 &public: __thiscall std::bad_alloc::bad_alloc(char const *)& (??0bad_alloc@std@@$$FQAE@PBD@Z) 中被引用
1&MSVCMRTD.lib(locale0_implib.obj) : error LNK2028: 无法解析的标记(0A0003B6) &struct std::_DebugHeapTag_t const & __cdecl std::_DebugHeapTag_func(void)& (?_DebugHeapTag_func@std@@$$FYAABU_DebugHeapTag_t@1@XZ),该标记在函数 &private: static void __cdecl std::locale::facet::_Facet_Register_m(class std::locale::facet *)& (?_Facet_Register_m@facet@locale@std@@$$FCAXPAV123@@Z) 中被引用
搜索更多相关主题的帖子:
来 自:神界
等 级:贵宾
威 望:367
帖 子:12742
专家分:49749
库有问题???
DO IT YOURSELF !
来 自:武汉
等 级:贵宾
威 望:30
帖 子:2780
专家分:6060
问题描述得不清不楚...
我总觉得授人以鱼不如授人以渔...
可是总有些SB叫嚣着:要么给代码给答案,要么滚蛋...
虽然我知道不要跟SB一般见识,但是我真的没修炼到宠辱不惊...
来 自:何方
等 级:版主
威 望:164
帖 子:6765
专家分:42085
&&得分:20&
引用库冲突
用vc写代码时候,常常都会遇到这样的问题的。
查下是那个依赖性的问题,试试把它除去看看
http://blog.sina.com.cn/s/blog_6fy9br.html
http://blog.sina.com.cn/s/blog_6fxvz4.html
两遍文章,你参考下
或者百度下那些错误信息。
vc 编写大一点的工程常常有这个问题的
我的博客:
http://blog.yuccn. net
版权所有,并保留所有权利。
Powered by , Processed in 0.032076 second(s), 7 queries.
Copyright&, BCCN.NET, All Rights Reserved说道wchar_t和char两个类型大家都不会陌生
wchar_t:在windows下是Unicode 16编码,也就是俗称宽字节
char:当然就是指一个字节,在windows下面默认是gbk编码的
所以在windows 下 wchar_t 转 char也就是编码转化
直接贴出wchar_t *字符串和char *字符串的集中互转方法
方法一:利用Windows的宏W2A,A2W
USES_CONVERSION;
char* test1 = W2A(L"我是宽字节");//转化成默认
wchar_t* test12 = A2W("我是窄字节");
方法二:利用Windows里的ATL里面的类CW2A和CA2W,在转换时候还可以顺便调整编码,不加第二个参数就是保持GBK不变
std::string test3 = CW2A(L"中文字符", CP_UTF8);//一般可以加一下第二个参数,顺便切换编码
std::wstring test4 = CA2W("中文字符");//一般不用加第二个参数
方法三:利用Windows API中的函数 WideCharToMultiByte 和 MultiByteToWideChar ,而且也是可以带自定义编码转换
以下函数用法: CharToWchar可以等效于CW2A,WcharToChar可以等效于CA2W
std::wstring CharToWchar(const char* c, size_t m_encode = CP_ACP)
int len = MultiByteToWideChar(m_encode, 0, c, strlen(c), NULL, 0);
wchar_t* m_wchar = new wchar_t[len + 1];
MultiByteToWideChar(m_encode, 0, c, strlen(c), m_wchar, len);
m_wchar[len] = '\0';
std::string WcharToChar(const wchar_t* wp, size_t m_encode = CP_ACP)
int len = WideCharToMultiByte(m_encode, 0, wp, wcslen(wp), NULL, 0, NULL, NULL);
char *m_char = new char[len + 1];
WideCharToMultiByte(m_encode, 0, wp, wcslen(wp), m_char, len, NULL, NULL);
m_char[len] = '\0';
方法四:将使用标准C的mbstowcs方法和wcstombs方法,且配合标准C的setlocale方法,这也是利用标准库跨平台的做法,
但是过程没法直接转成自定义的编码,需要额外转码。所以在Windows平台开发的话不推荐。
注意:方法四将留在后面的blog和iconv库一起作为笔记
wchar_t和char,WCHAR和CHAR的区别和互相转化
win32应用程序的低层winnt.h头文件:
#ifndef VOID
#define VOID void
typedef char CHAR;
typedef short SHORT;
C/C++多字节与宽字符串的相互转换
代码编译运行环境:VC++2012+Debug+Win321.问题描述char字符与wchar_t字符由于编码不同,所以在char*和wchar_t*之间使用强制类型转换达不到正确转换字符串的目的。考...
char 转wchar_t 及wchar_t转char
原文来自 http://haofu123.blog.163.com/blog/static//
利用widechartomultibyte来转换的函数
char与wchar_t(TCHAR)之间的相互转换
char与wchar_t(TCHAR)之间的相互转换1、wchar_t类型数据的初始化
char类型数据的初始化就不再骜述了;只说一下wchar_t类型的初始化:wchar_t[] = L&qu...
使用C++,实现&em&char&/em&与&em&wchar_t&/em&互转,w2c,c2w分别实现&em&wchar_t&/em&到&em&char&/em&的转换和&em&char&/em&到&em&wchar_t&/em&的转换
把char*转换为wchar_t*
用stdlib.h中的mbstowcs_s函数,可以通过下面的例子了解其用法:
char*CStr = &string to convert&;
wchar_t*和char*之间的互相转换的那些事
http://blog.csdn.net/hellward/article/details/5364927
最近在看一写PE文件格式的东西,想做一个读取PE文件信息的小工具,中间遇到将LPVOI...
c、c++ char*和wchar*互相转换
1. 问题描述  编写程序时通常会面对一些不同的编码格式,如Unicode和multibytes。在有关字符串的处理时尤其重要,系统编程时通常会遇到很多这样的问题,例如把wchar*的字符串转换为ch...
char wchar_t CString的相互转化
#include #include #include #include #include
@param cbCharSize: lpCharStr的字节个数,可以设为-1,如果以nul...
没有更多推荐了,c++ - Convert std::wstring to WCHAR* - Stack Overflow
to customize your list.
This site uses cookies to deliver our services and to show you relevant ads and job listings.
By using our site, you acknowledge that you have read and understand our , , and our .
Your use of Stack Overflow’s Products and Services, including the Stack Overflow Network, is subject to these policies and terms.
Join Stack Overflow to learn, share knowledge, and build your career.
or sign in with
I have no idea how to convert a
std::wstring to a WCHAR*
std::wstring wstrProcToS
WCHAR * wpProcToSearch = NULL;
std::wcin && wstrProcToS
// input std::wstring
// now i need to convert the wstring to a WCHAR*
Does anyone know how to accomplish this?
27.2k1060110
If you want to convert from std::wstring to const WCHAR* (i.e. the returned pointer gives read-only access to the string content), then calling std::wstring::c_str() method is just fine:
std::wstring wstrProcToS
std::wcin && wstrProcToS
// input std::wstring
// Convert to const WCHAR* (read-only access)
const WCHAR * wpszProcToSearch = wstrProcToSearch.c_str();
Instead, if you want to modify std::wstring's content, things are different. You can use &wstr[0] (where wstr is a non-empty instance of std::wstring) to access the content of the std::wstring (starting from the address of its first characters, and noting that characters are stored contiguously in memory), but you must pay attention to not overrun string's pre-allocated memory.
In general, if you have a std::wstring of length L, you can access characters from index 0
(located at index L) is undefined behavior (in practice, it's OK on Visual C++, at least with VC9/VS2008 and VC10/VS2010).
If the string has not the proper size (i.e. it's not big enough for your needs), then you can call std::wstring::resize() to make room for new characters (i.e. resizing internal std::wstring's buffer), and then use &wstr[0] to read-write std::wstring's content.
27.2k1060110
If the string is already the proper length and will not need to be changed, you can get a non-const pointer by taking a pointer to the first character:
WCHAR * wpProcToSearch = &wstrProcToSearch[0];
This is guaranteed to work in C++11 and there are no known implementations of C++03 where it doesn't.
If you only need a const pointer you should use c_str:
const WCHAR * wpProcToSearch = wstrProcToSearch.c_str();
216k28265486
I think you can use
wpProcToSearch = wstrProcToSearch.c_str()
like you do with a normal std::string.
13.3k1465123
I recommend this approach:
wstring str = L"Hallo
wchar_t* psStr = &str[0];
It is quite simple but you can not change the length of the string at all. So moving "\0" might not be valid...
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Post as a guest
Post as a guest
Post Your Answer
By clicking &Post Your Answer&, you acknowledge that you have read our updated ,
and , and that your continued use of the website is subject to these policies.
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabledc++中char*\wchar_t*\string\wstring之间的相互转换
时间: 09:12:19
&&&& 阅读:520
&&&& 评论:
&&&& 收藏:0
标签:&&&&&&&&&&&&&&&&&&&&&&&&&&&
最近在编程中经常遇到需要多字节字符与宽字节字符相互转换的问题,一直自己贴那几句代码。觉得麻烦,于是就自己写了一个类来封装wchar_t与char类型间的转换,
其他的,诸如:CString\ LPWSTR\TCHAR&& CHAR\LPSTR之间也是一样用
#ifndef USE_H_
#define USE_H_
#include &iostream&
#include &windows.h&
#include &string&
class CUser
virtual~ CUser();
char* WcharToChar(const wchar_t* wp);
char* StringToChar(const string& s);
char* WstringToChar(const wstring& ws);
wchar_t* CharToWchar(const char* c);
wchar_t* WstringToWchar(const wstring& ws);
wchar_t* StringToWchar(const string& s);
wstring StringToWstring(const string& s);
string WstringToString(const wstring& ws);
void Release();
wchar_t* m_
实现文件:
#include "stdafx.h"
#include "use.h"
CUser::CUser()
:m_char(NULL)
,m_wchar(NULL)
CUser::~CUser()
Release();
char* CUser::WcharToChar(const wchar_t* wp)
Release();
int len= WideCharToMultiByte(CP_ACP,0,wp,wcslen(wp),NULL,0,NULL,NULL);
m_char=new char[len+1];
WideCharToMultiByte(CP_ACP,0,wp,wcslen(wp),m_char,len,NULL,NULL);
m_char[len]=‘\0‘;
wchar_t* CUser::CharToWchar(const char* c)
Release();
int len = MultiByteToWideChar(CP_ACP,0,c,strlen(c),NULL,0);
m_wchar=new wchar_t[len+1];
MultiByteToWideChar(CP_ACP,0,c,strlen(c),m_wchar,len);
m_wchar[len]=‘\0‘;
void CUser::Release()
   if(m_char)&   &{&     delete [] m_&     &m_char=NULL;&   &}&   if(m_wchar)&   &{&     &delete [] m_&     &m_wchar=NULL;&   }
char* CUser::StringToChar(const string& s)
return const_cast&char*&(s.c_str());
char* CUser::WstringToChar(const std::wstring &ws)
const wchar_t* wp=ws.c_str();
return WcharToChar(wp);
wchar_t* CUser::WstringToWchar(const std::wstring &ws)
return const_cast&wchar_t*&(ws.c_str());
wchar_t* CUser::StringToWchar(const string& s)
const char* p=s.c_str();
return CharToWchar(p);
string CUser::WstringToString(const std::wstring &ws)
char* p=WstringToChar(ws);
s.append(p);
wstring CUser::StringToWstring(const std::string &s)
wchar_t* wp=StringToWchar(s);
ws.append(wp);
如果涉及到CString,可以利用CString::GetBuffer()函数来进行转换,道理一样.
使用的时候非常简单了:
WCHAR* wc=findData.cFileN
char* c=u.WcharToChar(wc);
标签:&&&&&&&&&&&&&&&&&&&&&&&&&&&原文:http://www.cnblogs.com/shouce/p/5062401.html
教程昨日排行
&&国之画&&&& &&&&&&
&& &&&&&&&&&&&&&&
鲁ICP备号-4
打开技术之扣,分享程序人生!

我要回帖

更多关于 VS2010学习版怎么显示错误 的文章

 

随机推荐