The Phone Number Utility is part of the Symbian Text Utility Component (etul.dll) and it offers methods for parsing and validating phone numbers.
Examples of valid phone numbers:
Even though both of the above examples are valid phone numbers, only the first one is accepted as a phone number by many systems. To convert the second number to the first number, parsing methods of Phone Number Utility can be used.
The TulPhoneNumberUtils class implements the static methods that make up the interface.
Phone Number Utility can be accessed through the TulPhoneNumberUtils class that is defined in the header tulphonenumberutils.h. This utility is linked to the etul.lib library.
Method Information
The enumerated type TPhoneNumberType is used to specify the type of phone number for some of the methods below.
Method name | Details |
---|---|
static TBool ParsePhoneNumber(TDes& aNumber, TPhoneNumberType aType) |
Removes irrelevant characters and white space from the supplied phone number. Allowed characters are determined by phone number type, in other words, the aType parameter. For example, parsing the number +358 (40) 123 467 results in the number +35840123467. |
static TBool IsValidPhoneNumber(const TDesC& aNumber, TPhoneNumberType aType) |
Checks if the supplied phone number is a valid phone number of the supplied type. |
TBool IsValidPhoneNumber(const TDesC& aNumber, const TDesC& aValidChars) |
Checks if the supplied phone number is a valid phone number. The phone number is valid if it contains only characters specified by the parameter aValidChars. |
static void ParseInvalidChars(TDes& aNumber, const TDesC& aInvalidChars) |
Removes the specified invalid characters from the supplied phone number string. |
Example
The following example shows how to use the TulPhoneNumberUtils class parsing methods:
TBuf<50> number = _L("+358 (40) 123 132"); TBool validNumber = TulPhoneNumberUtils::ParsePhoneNumber(number, TulPhoneNumberUtils::EPlainPhoneNumber ); // validNumber == ETrue; // number == "+35840123132" SendSMS(number) // etc.. // OR TBuf<50> number = _L("+358 (40) 123p132"); // note 'p' TBool validNumber = TulPhoneNumberUtils::ParsePhoneNumber(number, TulPhoneNumberUtils::EPlainPhoneNumber ); // validNumber == EFalse; // number == "+358 (40) 123p132" // unchanged
For more information on individual methods, please see the reference API for TulPhoneNumberUtils
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.