Symbian3/SDK/Source/GUID-6501FAFF-6E21-5BC8-BA85-B1B4CE1AC6A7.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Thu, 21 Jan 2010 18:18:20 +0000
changeset 0 89d6a7a84779
permissions -rw-r--r--
Initial contribution of Documentation_content according to Feature bug 1266 bug 1268 bug 1269 bug 1270 bug 1372 bug 1374 bug 1375 bug 1379 bug 1380 bug 1381 bug 1382 bug 1383 bug 1385

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-6501FAFF-6E21-5BC8-BA85-B1B4CE1AC6A7" xml:lang="en"><title>Phone
number utility overview</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<section id="GUID-648FA965-ED6E-432E-BE02-0AD632DA2630"><title>Purpose</title> <p>The
Phone Number Utility is part of the Symbian Text Utility Component (<codeph>etul.dll</codeph>)
and it offers methods for parsing and validating phone numbers. </p> <p>Examples
of valid phone numbers: </p> <ul>
<li id="GUID-C6D1DCE8-CC29-5C1D-840F-E22390F3F878"><p>1. +358501234567 </p> </li>
<li id="GUID-912697C8-0BFF-57BA-9B08-7D760F4E4F6F"><p>2. +358 (50) 123 4567 </p> </li>
</ul> <p>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. </p> </section>
<section id="GUID-CB2CAEEF-131E-48F2-A53E-3716C386E7C8"><title>Architectural
Relationships</title> <p>The <xref href="GUID-2ABFC65A-FA52-36AB-8910-99D3A10A2D66.dita"><apiname>TulPhoneNumberUtils</apiname></xref> class
implements the static methods that make up the interface. </p> <p>Phone Number
Utility can be accessed through the <xref href="GUID-2ABFC65A-FA52-36AB-8910-99D3A10A2D66.dita"><apiname>TulPhoneNumberUtils</apiname></xref> class
that is defined in the header <codeph>tulphonenumberutils.h</codeph>. This
utility is linked to the <codeph>etul.lib</codeph> library. </p> </section>
<section id="GUID-0C7FB3A9-2B7A-4576-B4A0-CDF706769D2C"><title>Description</title> <p><b>Method
Information</b> </p> <p>The enumerated type <xref href="GUID-2ABFC65A-FA52-36AB-8910-99D3A10A2D66.dita"><apiname>TPhoneNumberType</apiname></xref> is
used to specify the type of phone number for some of the methods below. </p> <table id="GUID-FD36C6FF-407D-5705-AE6E-62B2EC9D0C4E">
<tgroup cols="2"><colspec colname="col0"/><colspec colname="col1"/>
<thead>
<row>
<entry>Method name</entry>
<entry>Details</entry>
</row>
</thead>
<tbody>
<row>
<entry><p> <codeph>static TBool ParsePhoneNumber(TDes&amp; aNumber,      
               TPhoneNumberType aType)</codeph>  </p> </entry>
<entry><p>Removes irrelevant characters and white space from the supplied
phone number. Allowed characters are determined by phone number type, in other
words, the <codeph>aType</codeph> parameter. For example, parsing the number <codeph>+358
(40) 123 467</codeph> results in the number <codeph>+35840123467</codeph>. </p> </entry>
</row>
<row>
<entry><p> <codeph>static TBool IsValidPhoneNumber(const TDesC&amp; aNumber,
                     TPhoneNumberType aType)</codeph>  </p> </entry>
<entry><p>Checks if the supplied phone number is a valid phone number of the
supplied type. </p> </entry>
</row>
<row>
<entry><p> <codeph>TBool IsValidPhoneNumber(const TDesC&amp; aNumber, const
                     TDesC&amp; aValidChars)</codeph>  </p> </entry>
<entry><p>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 <codeph>aValidChars.</codeph>  </p> </entry>
</row>
<row>
<entry><p> <codeph>static void ParseInvalidChars(TDes&amp; aNumber, const
                     TDesC&amp; aInvalidChars)</codeph>  </p> </entry>
<entry><p>Removes the specified invalid characters from the supplied phone
number string. </p> </entry>
</row>
</tbody>
</tgroup>
</table> <p><b>Example</b> </p> <p>The following example shows how to use
the <codeph>TulPhoneNumberUtils</codeph> class parsing methods: </p> <codeblock id="GUID-BE0A3654-7CDF-536E-9392-D884E557163D" xml:space="preserve">TBuf&lt;50&gt; number = _L("+358 (40) 123 132");
TBool validNumber = TulPhoneNumberUtils::ParsePhoneNumber(number,
                        TulPhoneNumberUtils::EPlainPhoneNumber );
// validNumber == ETrue;
// number == "+35840123132"

SendSMS(number) // etc..

// OR

TBuf&lt;50&gt; number = _L("+358 (40) 123p132"); // note 'p'
TBool validNumber = TulPhoneNumberUtils::ParsePhoneNumber(number,
                        TulPhoneNumberUtils::EPlainPhoneNumber );

// validNumber == EFalse;
// number == "+358 (40) 123p132" // unchanged
</codeblock> <p>For more information on individual methods, please see the
reference API for <xref href="GUID-2ABFC65A-FA52-36AB-8910-99D3A10A2D66.dita"><apiname>TulPhoneNumberUtils</apiname></xref>  </p> </section>
</conbody></concept>