Reputation: 1
// this is the old MFC CString (not actually dependant on CObject) vs the new ATL version that is implemented as a template
char array[] = { 0x45, 0x46, 0x0, 0x45 };
CString a(array,sizeof array);
CString b;
int _aLen = a.GetLength();
// in vc6 _aLen is 4
// in vs2019 _aLen is 4
b += a;
int _bLen = b.GetLength();
// in vc6 _bLen is 4
// in vs2019 _bLen is 2! `
I can see why it is doing this. But.... Since we can give CString (one of its constructors) a pointer and a length and that actually works, why would an operator such as += or even the CString Append() function not use the length of the source string when it concatenates the string? This makes it extremely difficult to upgrade old projects to newer (visual studio) compilers. Is there a build/compile option I am missing here?
I tried changing unicode to MBCS with no difference. I also tried to step into the source but was unable to do that because I could not seem to get the source files to match the build. I was able to step into the disassembly and right up until the actual concatenation the string that was passed to operator += had length 4 but coming out the destination string only had length 2.
Upvotes: 0
Views: 125