symbian 描述符 TBuf和const char*的转换
2010-05-31 19:50:00 来源:WEB开发网核心提示:you may need to add extra checks (for instance, checking whether the char pointer is null or not).Converting descriptors to C-strings may be done this way:const
you may need to add extra checks (for instance, checking whether the char
pointer is null or not).
Converting descriptors to C-strings may be done this way:
const char* descriptorToStringL(const TDesC& aDescriptor)
{
TInt length = aDescriptor.Length();
HBufC8* buffer = HBufC8::NewLC(length);
buffer->Des().Copy(aDescriptor);
char* str = new(ELeave) char[length + 1];
Mem::Copy(str, buffer->Ptr(), length);
str[length] = '';
CleanupStack::PopAndDestroy(buffer);
return str;
}
更多精彩
赞助商链接