Sunday, June 12, 2005

 

Tip 8: Don't confuse Size() and Length().

The base class TDesC defines both Size() and Length() methods, which are easy to confuse.

Size()
returns the number of bytes the descriptor occupies.
Length() returns the number of characters the descriptor contains.

For 8-bit descriptors, where each character occupies a byte, this is the same thing. However, on all releases of Symbian OS since v5u, the native character width has been 16 bits; that is, each character occupies two bytes.

Thus, unless you're working with a very old SDK, you'll find that Size() always returns a value which is double that of Length().

This page is powered by Blogger. Isn't yours?

Google
WWW Top Tips for Descriptors