CString.Format(

    技术2022-05-11  114

    在vs.Net   2003   (Version   7.1.3088   English)的代码入下:     CString   m_strShow;     m_strShow.Format("%d",100);     在使用Use   Multi-Byte   Character   Set编译事一切正常;但是使用Use   Unicode   Character   Set选项编译时,出现如下的错误:       error   C2664:   'void   ATL::CStringT<BaseType,StringTraits>::Format(ATL::CSimpleStringT<BaseType,t_bMFCDLL>::PCXSTR,...)'   :   cannot   convert   parameter   1   from   'const   char   [3]'   to   'ATL::CSimpleStringT<BaseType,t_bMFCDLL>::PCXSTR'                     with                     [                             BaseType=wchar_t,                             StringTraits=StrTraitMFC_DLL<wchar_t>,                             t_bMFCDLL=true                     ]                     and                     [                             BaseType=wchar_t,                             t_bMFCDLL=true                     ]  

     Windows使用两种字符集ANSI和UNICODE,前者就是通常使用的单字节方式,但这种方式处理象中文这样的双字节字符不方便,容易出现半个汉字的情况。而后者是双字节方式,方便处理双字节字符。Windows NT的所有与字符有关的函数都提供两种方式的版本,而Windows 9x只支持ANSI方式。_T一般同字常数相关,如_T("Hello")。如果你编译一个程序为ANSI方式,_T实际不起任何作用。而如果编译一个程序为UNICODE方式,则编译器会把"Hello"字符串以UNICODE方式保存。_T和_L的区别在于,_L不管你是以什么方式编译,一律以以UNICODE方式保存。 


    最新回复(0)