API published in: S60 2nd Ed
Link against: commonengine.lib
Required Capabilities
None
#include <commonphoneparser.h>
Phone Parser API provides methods which are used to parse and validate phone numbers. The API consist of the CommonPhoneParser class.
Examples of valid phone numbers: 1. +358501234567 2. +358 (50) 123 4567
Even though both of the above examples are valid phone numbers, only 1) is accepted as a phone number by many systems. To convert 2) to 1), use the parsing method of the API.
Usage:
#include <commonphoneparser.h> // Example shows how to use the parsing method of the API. // A number to be parsed. TBuf<50> number1 = _L("+358 (40) 123 132"); // Type of the phone number to be parsed is a regular phone number. TBool validNumber1 = CommonPhoneParser::ParsePhoneNumber( number1, CommonPhoneParser::EPlainPhoneNumber ); // The phone number number1 is a valid regular phone number. // After parsing validNumber1 is ETrue and // number1 is "+35840123132". // Do something like SendSMS( number1 ) etc. // A number to be parsed. TBuf<50> number2 = _L("+358 (40) 123p132"); // note 'p' // Type of the phone number to be parsed is a regular phone number. TBool validNumber2 = CommonPhoneParser::ParsePhoneNumber( number2, CommonPhoneParser::EPlainPhoneNumber ); // The phone number number2 is not a valid regular phone number. // After parsing validNumber2 is EFalse and // number2 is "+358 (40) 123p132" (unchanged).
Public Types |
|
enum | TPhoneNumberType { EPlainPhoneNumber, EContactCardNumber, EPhoneClientNumber, ESMSNumber } |
Enumeration for phone number types. More... |
|
Static Public Member Functions |
|
static IMPORT_C TBool | ParsePhoneNumber (TDes &aNumber, TPhoneNumberType aType) |
Parses the supplied phone number. |
|
static IMPORT_C TBool | IsValidPhoneNumber (const TDesC &aNumber, TPhoneNumberType aType) |
Checks if string is a valid phone number. |
|
static TBool | IsValidPhoneNumber (const TDesC &aNumber, const TDesC &aValidChars) |
This method is meant for internal use of Phone Parser. |
|
static void | ParseInvalidChars (TDes &aNumber, const TDesC &aInvalidChars) |
This method is meant for internal use of Phone Parser. |
|
Enumeration for phone number types. Used to specify the type of phone numbers in methods of CommonPhoneParser class. |
|
This method is meant for internal use of Phone Parser. Check if string is a valid phone number
|
|
Checks if string is a valid phone number. This method checks if the supplied phone number is a valid phone number of the supplied type.
|
|
This method is meant for internal use of Phone Parser. Parses invalid characters from a string
|
|
Parses the supplied phone number. This method removes irrelevant characters and white spaces from the supplied phone number. Allowed characters are determined by phone number type.
|