when to use TBuf8 and TBuf16

Login to reply to this topic.
Tue, 2008-03-04 18:29
Joined: 2007-09-19
Forum posts: 18

I dont get when to use TBuf8 and TBuf16.. I know the
difference between them.
But plz tell me under what conditions do we have to
decide which descriptor should we use?

Plz help..


Wed, 2008-03-05 09:14
Joined: 2007-05-15
Forum posts: 14
Re: when to use TBuf8 and TBuf16

You're asking when to use TBufs (stack descriptors) and when to use heap descriptors?
If so then you can use TBufs when they are not too big (some say that it should be smaller than). But if you are using bigger TBuf ( for example TFileName ) you should avoid to use them as instance variable and only use them as local variable. But usually you should use heap descriptors like RBuf or HBufC.

Wed, 2008-03-05 09:54
Joined: 2004-11-29
Forum posts: 1233
Re: when to use TBuf8 and TBuf16

I think he is asking when to use 8bit descriptors and when to use 16 bits...

The answer is... it's up to yourself to chose whatever fits your needs Smiling

Generally, when you handle unicode text, you want to use 16 bit descriptors, since these are convenient then, because you will have one character per position in the descriptor.
If you instead want to keep general purpose binary data, or 8 bit ascii text, then you usually chose an 8 bit descriptor.
But.. sometimes you need to keep "8 bit data" in a 16 bit descriptor and vice versa, depending on what API functions you need to pass them to, and sometimes it makes sense to keep your binary data in a 16 bit descriptor.

So.. the only way to decide is to actually understand what the difference is, when the difference matters, and when it doesn't matter, you can't make a bullet proof list of "at this occasion you should always use 8 bit, and at this other occasion you should always use 16 bit."

Wed, 2008-03-05 14:51
Joined: 2007-09-19
Forum posts: 18
Re: when to use TBuf8 and TBuf16

hi,

thank you so much for the reply.. i'll definitely now make a list of apis according to their usage...

  • Login to reply to this topic.