我的代码:
int iLen2=0;
iLen=WideCharToMultiByte(CP_ACP,0,data.GetBuffer(),data.GetLength(),0,0,0,0);这里返回的ilen有没有包含结束符啊?我测试了一下,貌似没有包含呀
int iLen2=0;
iLen=WideCharToMultiByte(CP_ACP,0,data.GetBuffer(),data.GetLength(),0,0,0,0);这里返回的ilen有没有包含结束符啊?我测试了一下,貌似没有包含呀
迷糊迷糊~~
这里说的很清楚了,返回值里包含了空字符,new的时候不用+1
这个我看过了但是
我cstring里的内容是_T("123"),它返回的值是3,这个就让我很迷惑。如果包含空字符,那应该是4才对吧
new出来的东西溢出一两个字节很难发现的
http://msdn.microsoft.com/en-us/library/dd374130(VS.85).aspx
Return ValueReturns the number of bytes written to the buffer pointed to by lpMultiByteStr if successful. If the function succeeds and cbMultiByte is 0, the return value is the required size, in bytes, for the buffer indicated by lpMultiByteStr.The function returns 0 if it does not succeed. To get extended error information, the application can call GetLastError, which can return one of the following error codes: ERROR_INSUFFICIENT_BUFFER. A supplied buffer size was not large enough, or it was incorrectly set to NULL.
ERROR_INVALID_FLAGS. The values supplied for flags were not valid.
ERROR_INVALID_PARAMETER. Any of the parameter values was invalid.
ERROR_NO_UNICODE_TRANSLATION. Invalid Unicode was found in a string.