I have a problem, sometimes in the end of string I get many ????????? I don't know how to fix this, not to get that garbage. . .
USHORT length = (USHORT)d.GetLength();
if (length == 0) {
cEncodeJsonUtil->AddElement(dataHeader, L"null", false);
}
else {
WCHAR* buf = (WCHAR*)d.GetData();
//buf[length + 1] = L'\0'; //bugs like this as well as like buf[length]=L'\0';
// should I escape here or not ? is this + L'\0' ok ?S?!? Even after excaping still there is trash inside.
cEncodeJsonUtil->AddElement(dataHeader, (const WCHAR*)buf+ L'\0');
}
cEncodeJson->AddElement
just prints out element like this
wprintf(L"\n\"%s\" : \"%s\"\n", pwszKey, pwszValue);
Am I doing something wrong? Printing wrong? Should I maybe use:
swprintf(buf, L"%ls", buff); //to copy from the value I get to my own buffer?
Thanks a lot!