Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 14:21, 29 May 2008.

Comparing C strings and descriptors

From Forum Nokia Wiki

Introduction

Standard C strings and Symbian descriptors are by nature very different. The main difference is that descriptors know how many characters are in a data array. A C string doesn’t know its length, so when length is needed, the NULL character that indicates the end of the string has to be scanned.

Another difference arises with buffers. When C code reserves a buffer from the heap or stack, it has to keep the maximum length somewhere. Many C methods that alter the buffer contents do not respect the maximum size of the buffer and can override the reserved memory, causing unknown behavior. Buffer descriptors can tell the maximum length, and all the methods they provide respect the buffer limits.

When using neutral descriptor types there is no need to worry about character widths. In a C program, the programmer has to explicitly specify which method to use, for example strcat or wcscat.

Functions

- Write formatted data to a string

C string

sprintf, swprintf

Symbian descriptor

TDes::Format

- Append a string to another

C string

strcat, wcscat, strncat, wcsncat

Symbian descriptor

TDes::Append

- Compare strings lexicographically

C string

strcmp, strncmp, wcsncmp

Symbian descriptor

TDesC::Compare

- Copy a string to another

C string

strcpy, wcscpy, strncpy, wcsncpy

Symbian descriptor

TDes::Copy

- Find a character in a string

C string

strchr, wcschr

Symbian descriptor

TDesC::Locate

- Find a substring

C string

strstr, wcsstr

Symbian descriptor

TDesC::Find

- Get the length of a string

C string

strlen, wcslen

Symbian descriptor

TDesC::Length

- Compare strings using locale specific information

C string

strcoll, wcscoll

Symbian descriptor

TDesC::CompareC

- Format a time string

C string

strftime, wcsftime

Symbian descriptor

TDes::Format
Related Discussions
Thread Thread Starter Forum Replies Last Post
what is the localisation(.loc) file for? advocatee General Symbian C++ 1 2003-06-23 15:42
.jad descriptors jameswmohr Mobile Java General 0 2003-08-27 18:54
Bluetooth Output From Nokia 6300 stevejanko Mobile Java General 8 2007-07-21 09:33
Descriptors.. robbin123 General Symbian C++ 6 2006-06-16 12:23
Data Type problem Very Basic moja_a Carbide.c++ and CodeWarrior Tools 1 2008-03-18 17:11
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZmaemoQ
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX