Facing A Descriptor Issue.. plz resolve..
| Tue, 2007-09-25 13:36 | |
|
I am facing an error of unwanted garbage being printed along with required in the file. Class CMyViewvoid CMyView::HandleCommandL(TInt aCommand)When it is writting in the file it is writting those 18 bytes along with some garbage values also |
|






Forum posts: 1232
The problem is your calls to Ptr() that will return a raw pointer into the buffer.
When filling a descriptor from a raw pointer, it will read until it finds a NULL character.
BUT, descriptors are not NULL-terminated, so it will read on into memory until it happens to find a NULL character, and these extra reads are your garbage.
Try change your code to access the data only through the descriptors instead, (avoid the calls to Ptr()) and your problem will be solved.
Forum posts: 28
Thanks a lot.
But on changing the code... with rest same as given below.
void CMyView::HandleCommandL(TInt aCommand)
{
//Specific To A Case:
TInt len = iContainer->Data().Size();
TPtr16 lPtr((TUint16*)iContainer->Data().Ptr(),len);
TBuf8<200> buf8;
TBuf16<200> buf16(lPtr);
len = buf16.Length(); //Comes out to be 0
len = CnvUtfConverter::ConvertFromUnicodeToUtf8(buf8,buf16);
}
Would u please tell me why the length is coming as 0??
How to resolve it!!!!
Forum posts: 1232
You are still using calls to Ptr() in that code... Don't do that.
Your code should be able to look like this:
Also, in your TDes& CMyContainer :: Data(), you should not return iTemp->Des().
Instead do a
Consider returning a TDesC& instead of a TDes& too.
Forum posts: 28
Thanks a lot.
It has solved the problem.