Symbian3/SDK/Source/GUID-0B6C97D3-0E2D-5BBE-B8AC-985902715160.dita
changeset 0 89d6a7a84779
equal deleted inserted replaced
-1:000000000000 0:89d6a7a84779
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept id="GUID-0B6C97D3-0E2D-5BBE-B8AC-985902715160" xml:lang="en"><title>Using
       
    13 TDes16 class</title><shortdesc>Use TDes16 for Interfaces which take wide (Unicode) text regardless
       
    14 of the build variant.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    15 <section id="GUID-D4D5A59E-C9E5-5729-8730-5365C7922CFE"><title>Using in a
       
    16 function interface</title> <p>An interface which needs to access and modify
       
    17 Unicode text, regardless of the build variant, uses a <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TDes16</apiname></xref> as
       
    18 the argument type. All 16 bit concrete descriptors are derived from <codeph>TDes16</codeph> which
       
    19 means that the interface can accept any 16 bit descriptor.</p> <p>The following
       
    20 code fragment shows the most common function prototype pattern.</p> <codeblock id="GUID-70EBC544-5308-52AA-8777-0DFB5D73F7D0" xml:space="preserve">void ClassX::foo(TDes16&amp; anArg);</codeblock> <p>The
       
    21 use of <codeph>TDes16</codeph> means that data can be accessed and modified
       
    22 through the descriptor.</p> <p>In practice, nearly all code uses the build
       
    23 independent variant, <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TDes</apiname></xref>, unless an explicit
       
    24 8 bit or 16 bit build variant is required.</p> </section>
       
    25 <section id="GUID-C1F88768-4489-5A99-8512-7BE80C80EB25"><title>Accessing individual
       
    26 data items</title> <p>The code fragment illustrates the use of <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>operator[]()</apiname></xref>.</p> <p>The
       
    27 behaviour is the same for the build independent variant, <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TDes</apiname></xref>,
       
    28 replacing <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT16</apiname></xref> with <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT</apiname></xref>.</p> <codeblock id="GUID-CBB66254-2E53-5F18-A547-941CDE264B30" xml:space="preserve">_LIT16(KAtoG,"abcdefg");
       
    29 TChar ch;
       
    30 ...
       
    31 str.Length();           // returns 7
       
    32 ch = str[0];            // ch contains the character 'a'
       
    33 ch = str[3];            // ch contains the character 'd'
       
    34 ...
       
    35 str[0] = 'z';           // changes str to "zbcdefg"
       
    36 str[3] = 'z';           // changes str to "abczefg"
       
    37 ...
       
    38 ch = str[7];            // Panic !!
       
    39 str[7] = 'z';           // Panic !!</codeblock> </section>
       
    40 <section id="GUID-3E72CE9C-4C1A-5861-BCEE-B481809F5837"><title>Copying data</title> <p>The
       
    41 code fragment shows the <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>Copy()</apiname></xref> function.</p> <p>The
       
    42 behaviour is the same for the build independent variant, <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TDes</apiname></xref>,
       
    43 replacing <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT16</apiname></xref> with <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT</apiname></xref>,
       
    44 and <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf16</apiname></xref> with <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf</apiname></xref>.</p> <codeblock id="GUID-31357819-E92C-5D81-936D-8A31291CCCFD" xml:space="preserve">_LIT16(Kabcdefg,"abcdefg");
       
    45 _LIT16(Kabc,"abc");
       
    46 _LIT16(Kabcdefghi,"abcdefghi");
       
    47 ...
       
    48 TBuf16&lt;8&gt; str;
       
    49 ...
       
    50 str.Copy(Kabcdefg);     // copies "abcdefg" to str
       
    51 str.Length();           // returns 7
       
    52 str.MaxLength();        // returns 8
       
    53 ...
       
    54 str.Copy(Kabc);         // copies "abc" to str
       
    55 str.Length();           // returns 3
       
    56 str.MaxLength();        // returns 8
       
    57 ...
       
    58 str.Copy(Kabcdefghi));  // Panics !!</codeblock> </section>
       
    59 <section id="GUID-109A36A8-9FC0-59F0-96F5-A3BC86E07795"><title>Copying data
       
    60 with repetition</title> <p>The code fragment shows the <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>Repeat()</apiname></xref> function.</p> <p>The
       
    61 behaviour is the same for the build independent variant, <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TDes</apiname></xref>,
       
    62 replacing <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT16</apiname></xref> with <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT</apiname></xref>,
       
    63 and <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf16</apiname></xref> with <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf</apiname></xref>.</p> <codeblock id="GUID-02ABA404-871E-555B-BBC7-B7A2C5796D0F" xml:space="preserve">_LIT16(Kab,"ab");
       
    64 _LIT16(Kabc,"abc");
       
    65 _LIT16(Kabcde,"abcde");
       
    66 ...
       
    67 TBuf16&lt;8&gt; tgt(8);            // length of tgt is the same as the
       
    68 ...                          // maximum which is 8
       
    69 ...                          // following strings generated in tgt
       
    70 ...
       
    71 tgt.Repeat(Kab);             // "abababab"
       
    72 tgt.Repeat(Kabc);            // "abcabcab"
       
    73 tgt.Repeat(Kabcde);          // "abcdeabc"
       
    74 ...
       
    75 ...                          // changing length to 7 has the
       
    76 ...                          // following effect
       
    77 tgt.SetLength(7);
       
    78 tgt.Repeat(Kab);             // "abababa"
       
    79 tgt.Repeat(Kabc);            // "abcabca"
       
    80 tgt.Repeat(Kabcde);          // "abcdeab"</codeblock> </section>
       
    81 <section id="GUID-C7A4D40E-F4D3-5683-91DE-91FE2C5D63DE"><title>Copying data
       
    82 and justifying</title> <p>The code fragments show the <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>Justify()</apiname></xref> function.</p> <p>The
       
    83 behaviour is the same for the build independent variant, <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TDes</apiname></xref>,
       
    84 replacing <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT16</apiname></xref> with <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT</apiname></xref>,
       
    85 and <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf16</apiname></xref> with<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf</apiname></xref>.</p> <codeblock id="GUID-E8EEC5B9-846F-5352-9072-E7F19D751BFB" xml:space="preserve">_LIT16(Kabc,"abc");
       
    86 TBuf16&lt;16&gt; tgt(Kabc);
       
    87 ...
       
    88 tgt.Justify(_L("xyz"),8,ECenter,'@');</codeblock> <p>The descriptor <codeph>tgt</codeph> has
       
    89 a maximum length of 16 and initially holds the string "abc". After the call
       
    90 to <codeph>Justify()</codeph>, the content of <codeph>tgt</codeph> changes
       
    91 to <codeph>@@xyz@@@</codeph>.</p> <p>The content of the source descriptor
       
    92 is taken to form a field of length 8 which replaces the original content of
       
    93 the descriptor <codeph>tgt</codeph>. The characters <codeph>xyz</codeph> are
       
    94 centred within the new field and padded on both sides with the fill character <codeph>@</codeph>.</p> <p>Setting
       
    95 the alignment to <codeph>ELeft</codeph> would change the content of <codeph>tgt</codeph> to <codeph>"xyz@@@@@"</codeph> while
       
    96 setting the alignment to <codeph>ERight</codeph> would change the content
       
    97 of <codeph>tgt</codeph> to<codeph> "@@@@@xyz"</codeph>.</p> <p>In all three
       
    98 cases, the length of the descriptor <codeph>tgt</codeph> changes from 3 to
       
    99 8.</p> <codeblock id="GUID-084D5402-03A8-5A6C-ACBE-150594CC995F" xml:space="preserve">_LIT16(Kabc,"abc");
       
   100 _LIT16(Kxyz,"xyz");
       
   101 TBuf16&lt;8&gt; tgt(Kabc);
       
   102 ...
       
   103 tgt.Justify(Kxyz,9,ECenter,'@');</codeblock> <p>This call to <codeph>Justify()</codeph> panics
       
   104 because the resulting length of data in <codeph>tgt</codeph> exceeds the maximum
       
   105 length of <codeph>tgt</codeph>.</p> <codeblock id="GUID-620AA4E5-F6E8-5A68-B7D1-3D1D4549A5F6" xml:space="preserve">_LIT16(Kabc,"abc");
       
   106 _LIT16(KRtoZ,"rstuvwxyz");
       
   107 TBuf16&lt;16&gt; tgt(Kabc);
       
   108 ...
       
   109 tgt.Justify(KRtoZ,8,ECenter,'@');</codeblock> <p>In this call to <codeph>Justify()</codeph>,
       
   110 the content of <codeph>tgt</codeph> changes to "rstuvwxy". Only eight of the
       
   111 nine characters in the source literal<codeph>KRtoZ</codeph> are copied.</p> </section>
       
   112 <section id="GUID-73C9CA90-5D00-5CD3-853C-9C03AE44D052"><title>Copying conversion
       
   113 from signed integer to decimal character</title> <p>The following code fragment
       
   114 illustrates the use of<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>Num()</apiname></xref>.</p> <p>The
       
   115 behaviour is the same for the build independent variant, <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TDes</apiname></xref>,
       
   116 replacing <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf16</apiname></xref> with<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf</apiname></xref>.</p> <codeblock id="GUID-B57E9FE0-17F7-55EB-96DA-C1BEDA29A11C" xml:space="preserve">TBuf16&lt;16&gt; tgt;
       
   117 ...
       
   118 TInt numpos(176);
       
   119 TInt numneg(-176);
       
   120 ..                      // generates the following strings:
       
   121 tgt.Num(numpos);        // "176"
       
   122 tgt.Num(numneg);        // "-176"</codeblock> </section>
       
   123 <section id="GUID-9C8DC02F-C399-51EB-A675-FFF021626D88"><title>Copying conversion
       
   124 from unsigned integer to specified number system</title> <p>The following
       
   125 code fragment illustrates the use of<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>Num()</apiname></xref> and <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>NumUC()</apiname></xref>.</p> <p>The behaviour is the same for the
       
   126 build independent variant, <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TDes</apiname></xref>, replacing <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf16</apiname></xref> with<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf</apiname></xref>.</p> <codeblock id="GUID-EE8FAF1C-F74E-5CCB-B5D2-92298BE2B0A5" xml:space="preserve">TBuf16&lt;16&gt; tgt;    // generates the following strings:
       
   127 ...
       
   128 TUint number(170);
       
   129 ...
       
   130 tgt.Num(number,EBinary);     // "10101010"
       
   131 tgt.Num(number,EOctal);      // "252"
       
   132 tgt.Num(number,EDecimal);    // "170"
       
   133 tgt.Num(number,EHex);        // "aa"   &lt;-NB hex value in lower case
       
   134 tgt.NumUC(number,EHex);      // "AA"   &lt;-NB hex value in UPPER case
       
   135 tgt.Num(number);             // "170"  &lt;--EDecimal taken as default</codeblock> </section>
       
   136 <section id="GUID-E0D95020-9E74-5FE1-8A84-74FFE8C2CB1E"><title>Formatting
       
   137 text</title> <p>The following code fragments illustrate the various possibilities
       
   138 of<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>Format()</apiname></xref>.</p> <p>The behaviour is the
       
   139 same for the build independent variant, <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TDes</apiname></xref>,
       
   140 replacing <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT16</apiname></xref> with <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT</apiname></xref>,
       
   141 and <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf16</apiname></xref> with<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf</apiname></xref>.</p> <codeblock id="GUID-39F9392D-32CD-5CDF-B5B8-DBDDD708738F" xml:space="preserve">TBuf16&lt;256&gt; tgt;
       
   142 ...
       
   143 _LIT16(KFormat1,"[%b %c %d %o %u %x]");
       
   144 tgt.Format(KFormat1,65,65,65,65,65,65);//generates:
       
   145 ...                                  //[1000001 A 65 101 65 41]
       
   146 ...
       
   147 _LIT16(KFormat2,"[%04x]");           // pad char="0", field width=4
       
   148 tgt.Format(KFormat2,65);             //generates:
       
   149 ...                                  //[0041]
       
   150 ...
       
   151 _LIT16(KFormat3,"[%4x]");            // pad char=default, field width=4
       
   152 tgt.Format(KFormat3,65);             //generates:
       
   153 ...                                  //[  41]
       
   154 ...                                  // Note use of blanks as default pad chars.
       
   155 ...
       
   156 _LIT16(KFormat4,"[%*x]");            // fixed field width, taken from the arguments list
       
   157 tgt.Format(KFormat4,4,65);           //generates:
       
   158 ...                                  //[  41]
       
   159 ...
       
   160 ...
       
   161 _LIT16(KFormat5,"[%+$4d.00 %S]");    // pad char="$", field width=4, right aligned
       
   162 _LIT16(KOver,"over");                
       
   163 tgt.Format(KFormat5,65,&amp;KOver);      //generates:
       
   164 ...                                  //[$$65.00 over]
       
   165 ...
       
   166 _LIT16(KFormat6,"[%+4d.00 %S]");     // pad char=default, field width=4
       
   167 tgt.Format(KFormat6,65,&amp;KOver);      //generates:
       
   168 ...                                  //[  65.00 over]
       
   169 ...                                  //   note no pad char specified, defaults
       
   170 ...                                  //   to blank
       
   171 ...
       
   172 _LIT16(KFormat7,"[% 4d.00 %S]");     // pad char=" ", field width=4, alignment=default
       
   173 tgt.Format(KFormat7,65,&amp;KOver);      //generates:
       
   174 ...                                  //[  65.00 over]
       
   175 ...                                  //   note default right hand alignment and
       
   176 ...                                  //   blank pad char
       
   177 ...
       
   178 _LIT16(KFormat8,"[%+0*S]");          // right aligned, pad char="0", fixed field width
       
   179 _LIT16(KFred,"fred");                
       
   180 tgt.Format(KFormat8,10,&amp;KFred);      //generates:
       
   181 ...                                  //[000000fred]
       
   182 ...                                  // Note: 10 characters generated
       
   183 ...
       
   184 _LIT16(KFormat9,"[%=*6x]");          // centre aligned, pad char taken from arguments list, field width=6
       
   185 tgt.Format(KFormat9,'*',65);         //generates:
       
   186 ...                                  //[**41**]
       
   187 ...
       
   188 _LIT16(KFormat10,"[%+**d]");         // right aligned, pad char and field width taken from arguments list
       
   189 tgt.Format(KFormat10,'.',10,(-65));  //generates:
       
   190 ...                                  //[.......-65]
       
   191 ...
       
   192 _LIT16(KFormat11,"[%-A4p]");         // left aligned, field width=4, pad char="A"
       
   193 tgt.Format(KFormat11,65);            //generates
       
   194 ...                                  //[AAAA]
       
   195 ...                                  //   and makes no use of the argument list
       
   196 ...
       
   197 _LIT16(KFormat12,"[%m]");            //generates:
       
   198 tgt.Format(KFormat12,4660);          //   the char '['
       
   199 ...                                  //   followed by a byte with 0x12
       
   200 ...                                  //   followed by a byte with 0x34
       
   201 ...                                  //   followed by the char ']'
       
   202 _LIT16(KFormat13,"[%M]")
       
   203 tgt.Format(KFormat13,4660);          //generates:
       
   204 ...                                  //   the char '['
       
   205 ...                                  //   followed by a byte with 0x00
       
   206 ...                                  //   followed by a byte with 0x00
       
   207 ...                                  //   followed by a byte with 0x12
       
   208 ...                                  //   followed by a byte with 0x34
       
   209 ...                                  //   followed by the char ']'
       
   210 ...
       
   211 _LIT16(KFormat14,"[%w]");            //generates:
       
   212 tgt.Format(KFormat14,4660);          //   the char '['
       
   213 ...                                  //   followed by a byte with 0x34
       
   214 ...                                  //   followed by a byte with 0x12
       
   215 ...                                  //   followed by the char ']'
       
   216 ..
       
   217 _LIT16(KFormat15,"[%w]");            //generates:
       
   218 tgt.Format(KFormat15,4660);          //   the char '['
       
   219 ...                                  //   followed by a byte with 0x34
       
   220 ...                                  //   followed by a byte with 0x12
       
   221 ...                                  //   followed by a byte with 0x00
       
   222 ...                                  //   followed by a byte with 0x00
       
   223 ...                                  //   followed by the char ']'
       
   224 ...
       
   225 _LIT16(KFormat16,"[%6.2e]");         
       
   226 tgt.Format(KFormat16,3.4555);        //generates:
       
   227 ...                                  //[3.46E+00]
       
   228 _LIT16(KFormat17,"[%6.2f]");         
       
   229 tgt.Format(KFormat17,3.4555);        //generates:
       
   230 ...                                  //[  3.46]
       
   231 _LIT16(KFormat18,"[%6.2g]");         
       
   232 tgt.Format(KFormat18,3.4555);        //generates:
       
   233                                      //[3.4555]
       
   234 ...
       
   235 // Variable  argument positions
       
   236 _LIT16(KFormat19,"[%d %d]");          // implicit ordering
       
   237 tgt.Format(KFormat19,9,5);           // generates:
       
   238 ...                                  // [9 5]
       
   239 ...
       
   240 _LIT16(KFormat20,"[%$2$d %$1$d]");    // explicit ordering
       
   241 tgt.Format(KFormat20,9,5);           // generates:
       
   242 ...                                  // [5 9]
       
   243 ...
       
   244 _LIT16(KFormat21,"[%$1$d %$2$d]");    // explicit ordering (same as the implicit order)
       
   245 tgt.Format(KFormat21,9,5);           // generates:
       
   246 ...                                  // [9 5]
       
   247 
       
   248 // Using argument blocks (a many-to-one mapping between arguments and conversion specifiers)
       
   249 _LIT16(KFormat22,"[%0*d %d %d]");     // implicit ordering
       
   250 tgt.Format(KFormat22,3,9,5,12);      // generates:
       
   251 ...                                  // [009 5 12]
       
   252 ...
       
   253 _LIT16(KFormat23,"[%$2$d %$1$0*d %d]"); // mixed explicit and implicit ordering
       
   254 tgt.Format(KFormat23,3,9,5,12);      // generates:
       
   255 ...                                  // [5 009 12]
       
   256 ...                                  
       
   257 _LIT16(KFormat24,"[%$3$d %$1$0*d %$2$d]"); // explicit ordering
       
   258 tgt.Format(KFormat24,3,9,5,12);      // generates:
       
   259 ...                                  // [12 009 5]
       
   260 
       
   261 </codeblock> </section>
       
   262 <section id="GUID-6500B0CB-54FF-5358-A27F-16F42C4111C8"><title>Inserting data</title> <p>The
       
   263 code fragment shows the <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>Insert()</apiname></xref> function.</p> <p>The
       
   264 behaviour is the same for the build independent variant, <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TDes</apiname></xref>,
       
   265 replacing <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT16</apiname></xref> with <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT</apiname></xref>,
       
   266 and <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf16</apiname></xref> with<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf</apiname></xref>.</p> <codeblock id="GUID-BB71E3D6-2BE0-5687-A030-1C030D1D4D7A" xml:space="preserve">_LIT16(Kabc,"abc")
       
   267 _LIT16(KUVWXYZ,"UVWXYZ")
       
   268 _LIT16(KVWXYZ,"VWXYZ")
       
   269 _LIT16(KWXYZ,"WXYZ")
       
   270 _LIT16(KXYZ,"XYZ)
       
   271 ...
       
   272 TBuf16&lt;8&gt; tgt(3);
       
   273 ...                              // generates the strings:
       
   274 tgt = Kabc;
       
   275 tgt.Insert(0,kXYZ);              // "XYZabc"
       
   276 ...
       
   277 tgt = Kabc;
       
   278 tgt.Insert(1,KXYZ);              // "aXYZbc"
       
   279 ...
       
   280 tgt = Kabc;
       
   281 tgt.Insert(tgt.Length(),KXYZ);   // "abcXYZ"
       
   282 ...
       
   283 tgt = Kabc;
       
   284 tgt.Insert(tgt.Length()+1,KXYZ); // ----&gt; Panic !!
       
   285 ...
       
   286 tgt = Kabc;
       
   287 tgt.Insert(1,KWXYZ);             // "aWXYZbc"
       
   288 ...
       
   289 tgt = Kabc;
       
   290 tgt.Insert(1,KVWXYZ);            // "aVWXYZbc"
       
   291 ...
       
   292 tgt = Kabc;
       
   293 tgt.Insert(1,KUVWXYZ);           // ----&gt; Panic !!</codeblock> </section>
       
   294 <section id="GUID-1A3976EB-6A46-5F6F-B190-ACEA13474EBD"><title>Replacing data</title> <p>The
       
   295 following code fragment illustrates the use of<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>Replace()</apiname></xref>.</p> <p>The
       
   296 behaviour is the same for the build independent variant, <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TDes</apiname></xref>,
       
   297 replacing <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT16</apiname></xref> with <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT</apiname></xref>,
       
   298 and <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf16</apiname></xref> with<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf</apiname></xref>.</p> <codeblock id="GUID-13F5FDC8-07DA-5818-A2DF-7F58757C4558" xml:space="preserve">_LIT16(Kabcd,"abcd");
       
   299 _LIT16(Ku,"u");
       
   300 _LIT16(Kuv,"uv");
       
   301 _LIT16(Kuvw,"uvw");
       
   302 _LIT16(Kuvwxyz,"uvwxyz");
       
   303 ...
       
   304 TBuf16&lt;8&gt; tgt(4);
       
   305 ...                          // generates the strings:
       
   306 tgt = Kabcd;
       
   307 tgt.Replace(0,1,Ku));        // "ubcd"
       
   308 ...
       
   309 tgt = Kabcd;
       
   310 tgt.Replace(0,1,Kuv);        // "uvbcd"
       
   311 ...
       
   312 tgt = Kabcd;
       
   313 tgt.Replace(0,1,Kuvw);       // "uvwbcd"
       
   314 ...
       
   315 tgt = Kabcd;
       
   316 tgt.Replace(0,1,Kuvwxyz);    // ----&gt; Panics !!
       
   317 ...
       
   318 tgt = Kabcd;
       
   319 tgt.Replace(1,2,Ku);         // "aud"
       
   320 ...
       
   321 tgt = Kabcd;
       
   322 tgt.Replace(1,2,KNullDesC16);// "ad"
       
   323 ...
       
   324 tgt = Kabcd;
       
   325 tgt.Replace(1,4,Kuvw);       // ----&gt; Panics !!
       
   326 ...
       
   327 tgt = Kabcd;
       
   328 tgt.Replace(3,1,Kuvw);       // "abcuvw"
       
   329 ...
       
   330 tgt = Kabcd;
       
   331 tgt.Replace(4,0,Kuvw);       // "abcduvw"</codeblock> </section>
       
   332 <section id="GUID-1F92A7F4-2206-5B60-B020-AFAB4720DC54"><title>Swapping data</title> <p>This
       
   333 code fragment shows the <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>Swap()</apiname></xref> function.</p> <p>The
       
   334 behaviour is the same for the build independent variant, <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TDes</apiname></xref>,
       
   335 replacing <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT16</apiname></xref> with <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT</apiname></xref>,
       
   336 and <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf16</apiname></xref> with<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf</apiname></xref>.</p> <codeblock id="GUID-79B2CD79-D203-5958-9738-4DD9EF91D659" xml:space="preserve">_LIT16(Kabcde,"abcde");
       
   337 _LIT16(Kxyz,"xyz");
       
   338 _LIT16(K0to9,"0123456789");
       
   339 ...
       
   340 TBuf16&lt;8&gt;  buf1(Kabcde);
       
   341 TBuf16&lt;8&gt;  buf2(Kxyz);
       
   342 TBuf16&lt;16&gt; buf3(K0to9);
       
   343 ...
       
   344 buf1.Swap(buf2);    // contents of buf1 and buf2 swapped OK
       
   345 buf1.Swap(buf3);    // Panic !!</codeblock> </section>
       
   346 <section id="GUID-883167BC-E97D-5826-AA1A-41D1C3F0BF18"><title>Deleting data</title> <p>The
       
   347 following code fragment illustrates the use of<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>Delete()</apiname></xref>.</p> <p>The
       
   348 behaviour is the same for the build independent variant, <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TDes</apiname></xref>,
       
   349 replacing <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT16</apiname></xref> with <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT</apiname></xref>,
       
   350 and <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf16</apiname></xref> with<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf</apiname></xref>.</p> <codeblock id="GUID-0EB429E5-BAC6-502B-B73C-16EC701AA439" xml:space="preserve">_LIT16(Kabcd,"abcd");
       
   351 ...
       
   352 TBuf16&lt;8&gt; tgt(4);
       
   353 ...                         // generates the strings:
       
   354 tgt = Kabcd;
       
   355 tgt.Delete(0,1);            // "bcd"
       
   356 ...
       
   357 tgt = Kabcd;
       
   358 tgt.Delete(0,2);            // "cd"
       
   359 ...
       
   360 tgt = Kabcd;
       
   361 tgt.Delete(0,4);            // ""
       
   362 ...
       
   363 tgt = Kabcd;
       
   364 tgt.Delete(1,2);            // "ad"
       
   365 ...
       
   366 tgt = Kabcd;
       
   367 tgt.Delete(2,2);            // "ab"
       
   368 ...
       
   369 tgt = Kabcd;
       
   370 tgt.Delete(2,3);            // "ab"
       
   371 ...
       
   372 tgt = Kabcd;
       
   373 tgt.Delete(2,256);          // "ab"
       
   374 ...
       
   375 tgt = Kabcd;
       
   376 tgt.Delete(5,1);            // ----&gt; Panics !!
       
   377 ...
       
   378 tgt = Kabcd;
       
   379 tgt.Delete(-1,1);           // ----&gt; Panics !!</codeblock> </section>
       
   380 <section id="GUID-19E04508-8752-50BC-9570-4DF826461F8B"><title>Deleting leading
       
   381 spaces</title> <p>The following code fragment illustrates the use of<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TrimLeft()</apiname></xref>.</p> <p>The behaviour is the same for
       
   382 the build independent variant, <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TDes</apiname></xref>, replacing <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT16</apiname></xref> with <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT</apiname></xref>,
       
   383 and <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf16</apiname></xref> with<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf</apiname></xref>.</p> <codeblock id="GUID-95FD982B-0398-5BA8-AA26-79EB6CEC0193" xml:space="preserve">_LIT16(KData1,"  abcd  ");
       
   384 _LIT16(KData2," a b ");
       
   385 ...
       
   386 TBuf16&lt;8&gt; str1(KData1);
       
   387 TBuf16&lt;8&gt; str2(KData2);
       
   388 ...
       
   389 str1.Length();          // returns 8
       
   390 str1.TrimLeft();        // "abcd  "
       
   391 str1.Length();          // returns 6
       
   392 ...
       
   393 str2.Length();          // returns 5
       
   394 str2.TrimLeft();        // "a b "
       
   395 str2.Length();          // returns 4</codeblock> </section>
       
   396 <section id="GUID-2EB9B1C4-A39A-5696-B0F0-9CC6DFD8AE44"><title>Deleting trailing
       
   397 spaces</title> <p>The following code fragment illustrates the use of<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TrimRight()</apiname></xref>.</p> <p>The behaviour is the same for
       
   398 the build independent variant, <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TDes</apiname></xref>, replacing <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT16</apiname></xref> with <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT</apiname></xref>,
       
   399 and <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf16</apiname></xref> with<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf</apiname></xref>.</p> <codeblock id="GUID-EC730EBE-BD56-5E95-AAA3-B704CA19C189" xml:space="preserve">_LIT16(KData1,"  abcd  ");
       
   400 _LIT16(KData2," a b ");
       
   401 ...
       
   402 TBuf16&lt;8&gt; str1(KData1);
       
   403 TBuf16&lt;8&gt; str2(KData2);
       
   404 ...
       
   405 str1.Length();          // returns 8
       
   406 str1.TrimRight();       // "  abcd"
       
   407 str1.Length();          // returns 6
       
   408 ...
       
   409 str2.Length();          // returns 5
       
   410 str2.TrimRight();       // " a b"
       
   411 str2.Length();          // returns 4</codeblock> </section>
       
   412 <section id="GUID-94016BAD-FED1-5BDB-875A-E9C03D1C400F"><title>Deleting leading
       
   413 and trailing spaces</title> <p>The following code fragment illustrates the
       
   414 use of<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>Trim()</apiname></xref>.</p> <p>The behaviour is the
       
   415 same for the build independent variant, <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TDes</apiname></xref>,
       
   416 replacing <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT16</apiname></xref> with <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT</apiname></xref>,
       
   417 and <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf16</apiname></xref> with<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf</apiname></xref>.</p> <codeblock id="GUID-6446EB8B-AF08-53B4-8554-5DE6639BDD5C" xml:space="preserve">_LIT16(KData1,"  abcd  ");
       
   418 _LIT16(KData2," a b ");
       
   419 ...
       
   420 TBuf16&lt;8&gt; str1(KData1);
       
   421 TBuf16&lt;8&gt; str2(KData2);
       
   422 ...
       
   423 str1.Length();          // returns 8
       
   424 str1.Trim();            // "abcd"
       
   425 str1.Length();          // returns 4
       
   426 ...
       
   427 str2.Length();          // returns 5
       
   428 str2.Trim();            // "a b"
       
   429 str2.Length();          // returns 3</codeblock> </section>
       
   430 <section id="GUID-804382DD-9790-5E11-A6F4-112DA7C30C1E"><title>Deleting leading,
       
   431 trailing and internal spaces</title> <p>The following code fragment illustrates
       
   432 the use of<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TrimAll()</apiname></xref>.</p> <p>The behaviour
       
   433 is the same for the build independent variant, <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TDes</apiname></xref>,
       
   434 replacing <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT16</apiname></xref> with <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT</apiname></xref>,
       
   435 and <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf16</apiname></xref> with<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf</apiname></xref>.</p> <codeblock id="GUID-101C5202-1FCA-5720-AA6C-6006229BBAE7" xml:space="preserve">_LIT16(KData1,"  abcd  ");
       
   436 _LIT16(KData2," a b ");
       
   437 _LIT16(KData3,"a  b   c");
       
   438 ...
       
   439 TBuf16&lt;8&gt; str1(KData1);
       
   440 TBuf16&lt;8&gt; str2(KData2);
       
   441 TBuf16&lt;8&gt; str2(KData3);
       
   442 ...
       
   443 str1.Length();          // returns 8
       
   444 str1.TrimAll();         // "abcd"
       
   445 str1.Length();          // returns 4
       
   446 ...
       
   447 str2.Length();          // returns 5
       
   448 str2.TrimAll();         // "a b"
       
   449 str2.Length();          // returns 3
       
   450 ...
       
   451 str3.Length();          // returns 8
       
   452 str3.TrimAll();         // "a b c"
       
   453 str3.Length();          // returns 5</codeblock> </section>
       
   454 <section id="GUID-B84DE2E8-6E4B-509C-9A43-F1134736BA04"><title>Append and
       
   455 justify</title> <p>The following code fragments illustrate the use of<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>AppendJustify()</apiname></xref>.</p> <p>The behaviour is the same
       
   456 for the build independent variant, <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TDes</apiname></xref>,
       
   457 replacing <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT16</apiname></xref> with <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT</apiname></xref>,
       
   458 and <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf16</apiname></xref> with<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf</apiname></xref>.</p> <codeblock id="GUID-88672250-8C80-5AA4-B26A-44E73FD2C90E" xml:space="preserve">_LIT16(Kabc,"abc");
       
   459 _LIT16(Kxyz, "xyz");
       
   460 ...
       
   461 TBuf16&lt;16&gt; tgt(Kabc);
       
   462 tgt.AppendJustify(Kxyz,8,ECenter,'@');</codeblock> <p>The descriptor <codeph>tgt</codeph> has
       
   463 a maximum length of 16 and initially holds the string "<codeph>abc</codeph>".
       
   464 After the call to <codeph>AppendJustify()</codeph>, the content of <codeph>tgt</codeph> changes
       
   465 to "<codeph>abc@@xyz@@@</codeph>".</p> <p>The content of the source descriptor <codeph>Kxyz</codeph> is
       
   466 taken to form a field of length 8 which is appended to the content of the
       
   467 descriptor <codeph>tgt</codeph>. The characters "<codeph>xyz</codeph>" are
       
   468 centred within the new field and padded on both sides with the fill character <codeph>'@'.</codeph></p> <p>Setting
       
   469 the alignment to <codeph>ELeft</codeph> would change the content of <codeph>tgt</codeph> to
       
   470 "<codeph>abcxyz@@@@@</codeph>" while setting the alignment to <codeph>ERight</codeph> would
       
   471 change the content of <codeph>tgt</codeph> to "<codeph>abc@@@@@xyz</codeph>".</p> <p>In
       
   472 all three cases, the length of the descriptor <codeph>tgt</codeph> changes
       
   473 from 3 to 11.</p> <codeblock id="GUID-F5C0525B-CAAD-5068-8C54-28A7EFBA02A3" xml:space="preserve">_LIT16(KAtoK,"abcdefghik");
       
   474 _LIT16(K0to6,"0123456");
       
   475 ...
       
   476 TBuf16&lt;16&gt; tgt(KAtoK);
       
   477 tgt.AppendJustify(K0to6,7,ECenter,'@');</codeblock> <p>This call to <codeph>AppendJustify()</codeph> panics
       
   478 because the resulting length of <codeph>tgt</codeph> exceeds its maximum length.</p> </section>
       
   479 <section id="GUID-A6018CB3-8452-5A6E-876A-337D7496D2A3"><title>Append and
       
   480 justify with explicit length</title> <p>The following code fragments illustrate
       
   481 the use of the overloaded version of <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>AppendJustify()</apiname></xref> which
       
   482 specifies an explicit length.</p> <p>The behaviour is the same for the build
       
   483 independent variant, <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TDes</apiname></xref>, replacing <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT16</apiname></xref> with <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT</apiname></xref>,
       
   484 and <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf16</apiname></xref> with<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf</apiname></xref>.</p> <codeblock id="GUID-D5496168-D727-574C-A2C3-C23ABCC3DA23" xml:space="preserve">_LIT16(Kabc,"abc");
       
   485 _LIT16(Kxyz0to9,"xyz0123456789");
       
   486 ...
       
   487 TBuf16&lt;16&gt; tgt(Kabc);
       
   488 tgt.AppendJustify(Kxyz0to9,3,8,ECenter,'@');</codeblock> <p>The descriptor <codeph>tgt</codeph> has
       
   489 a maximum length of 16 and initially holds the string "<codeph>abc</codeph>".
       
   490 After the call to <codeph>AppendJustify()</codeph>, the content of <codeph>tgt</codeph> changes
       
   491 to "<codeph>abc@@xyz@@@</codeph>".</p> <p>In this example, the first three
       
   492 characters of the eleven characters "<codeph>xyz0123456789</codeph>" are taken
       
   493 to form an eight character field which is appended to the existing content
       
   494 of the descriptor <codeph>tgt</codeph>. The three characters "<codeph>xyz</codeph>"
       
   495 are centred within the new field and padded on both sides with the fill character <codeph>'@'.</codeph></p> <p>Setting
       
   496 the alignment to <codeph>ELeft</codeph> would change the content of <codeph>tgt</codeph> to <codeph>"abcxyz@@@@@"</codeph> while
       
   497 setting the alignment to <codeph>ERight</codeph> would change the content
       
   498 of <codeph>tgt</codeph> to "<codeph>abc@@@@@xyz</codeph>".</p> <p>In all three
       
   499 cases, the length of the descriptor <codeph>tgt</codeph> changes from 3 to
       
   500 11.</p> <codeblock id="GUID-7ADD1986-D57E-55B3-8C78-EDF7E8C97F3A" xml:space="preserve">_LIT16(Kabc,"abc");
       
   501 _LIT16(K0to9,"0123456789");
       
   502 ...
       
   503 TBuf16&lt;16&gt; tgt(Kabc);
       
   504 tgt.AppendJustify(K0to9,9,8,ECenter,'@');</codeblock> <p>In this example,
       
   505 the call to <codeph>AppendJustify()</codeph> changes the content of <codeph>tgt</codeph> to
       
   506 "<codeph>abc01234567</codeph>". As the specified length is greater than the
       
   507 specified width, the length is truncated so that only eight characters are
       
   508 copied from the source descriptor.</p> <codeblock id="GUID-DC7F6C77-14D0-5922-AD4A-C5CCE2B99A81" xml:space="preserve">_LIT16(KAtoK,"abcdefghik");
       
   509 _LIT16(K0to9,"0123456789");
       
   510 ...
       
   511 TBuf16&lt;16&gt; tgt(KAtoK);
       
   512 tgt.AppendJustify(K0to9,3,7,ECenter,'@');</codeblock> <p>This call to <codeph>AppendJustify()</codeph> panics
       
   513 because the resulting length of <codeph>tgt</codeph> exceeds its maximum length.</p> </section>
       
   514 <section id="GUID-E844DB49-2BDA-56BD-92AB-5FB23D2274D2"><title>Append data
       
   515 operator</title> <p>The following code fragment illustrates the use of<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>operator+=()</apiname></xref>.</p> <codeblock id="GUID-F8E72C51-2DAA-5AB9-ADB3-AA1830020116" xml:space="preserve">_LIT16(Kabc,"abc");
       
   516 TBuf16&lt;16&gt; tgt(Kabc);
       
   517 ...
       
   518 tgt+=(_L("0123456789"));         // generates "abc0123456789"
       
   519 tgt+=(_L("0123456789qwerty"));   // Panics !!</codeblock> </section>
       
   520 <section id="GUID-F056485E-28FF-5E20-82D7-884D486174E3"><title>Append conversion
       
   521 from signed integer to decimal character</title> <p>The following code fragment
       
   522 illustrates the use of<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>AppendNum()</apiname></xref>.</p> <p>The
       
   523 behaviour is the same for the build independent variant, <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TDes</apiname></xref>,
       
   524 replacing <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf16</apiname></xref> with<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf</apiname></xref>.</p> <codeblock id="GUID-14953E84-47E5-5BA5-8EB8-11E4A062A8A9" xml:space="preserve">_LIT16(Kabc,"abc");
       
   525 TInt numpos(176);
       
   526 TInt numneg(-176);
       
   527 ...
       
   528 TBuf16&lt;16&gt; tgt(Kabc));       // generates the following strings:
       
   529 tgt.AppendNum(numpos);       // "abc176"
       
   530 tgt.AppendNum(numneg);       // "abc-176"</codeblock> </section>
       
   531 <section id="GUID-0B59128B-2152-5CB3-8363-457CDB18768D"><title>Append conversion
       
   532 from unsigned integer to specified number system</title> <p>The following
       
   533 code fragment illustrates the use of<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>AppendNum()</apiname></xref> and <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>AppendNumUC()</apiname></xref>.</p> <p>The behaviour is the same
       
   534 for the build independent variant, <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TDes</apiname></xref>,
       
   535 replacing <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT16</apiname></xref> with <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT</apiname></xref>,
       
   536 and <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf16</apiname></xref> with<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf</apiname></xref>.</p> <codeblock id="GUID-0DBF2078-5B45-5865-9B15-14ED2C29DC27" xml:space="preserve">_LIT16(Kabc,"abc");
       
   537 TBuf16&lt;16&gt; tgt(Kabc);  // generates the following strings:
       
   538 ...
       
   539 TUint num(170);
       
   540 ...
       
   541 tgt.AppendNum(num,EBinary);  // "abc10101010"
       
   542 tgt.AppendNum(num,EOctal);   // "abc252"
       
   543 tgt.AppendNum(num,EDecimal); // "abc170"
       
   544 tgt.AppendNum(num,EHex);     // "abcaa"   &lt;-hex value in lower case
       
   545 tgt.AppendNumUC(num,EHex);   // "abcAA"   &lt;-hex value in UPPER case
       
   546 tgt.AppendNum(num);          // "abc170"  &lt;-EDecimal taken as default</codeblock> </section>
       
   547 <section id="GUID-7A61CC57-7AC3-5AFD-9E3F-1FFAD4D9EF3E"><title>Append fixed
       
   548 width conversion</title> <p>The following code fragment illustrates the use
       
   549 of<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>AppendNumFixedWidth()</apiname></xref> and<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>AppendNumFixedWidthUC()</apiname></xref>.</p> <p>The
       
   550 behaviour is the same for the build independent variant, <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TDes</apiname></xref>,
       
   551 replacing <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT16</apiname></xref> with <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>_LIT</apiname></xref>,
       
   552 and <xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf16</apiname></xref> with<xref href="GUID-C04A9A0C-DBA7-37DA-B744-54FBF3D544CD.dita"><apiname>TBuf</apiname></xref>.</p> <codeblock id="GUID-344F9FBD-83BC-599C-A762-ED7CBD5ED060" xml:space="preserve">_LIT16(Kabc,"abc");
       
   553 TBuf16&lt;16&gt; tgt(Kabc);  // generates the following strings:
       
   554 ...
       
   555 TUint num(170)
       
   556 ...
       
   557 tgt.AppendNumFixedWidth(num,EBinary,8);     // "abc10101010"
       
   558 tgt.AppendNumFixedWidth(num,EOctal,8);      // "abc00000252"
       
   559 tgt.AppendNumFixedWidth(num,EDecimal,8);    // "abc00000170"
       
   560 tgt.AppendNumFixedWidth(num,EHex,8);        // "abc000000aa"
       
   561 tgt.AppendNumFixedWidthUC(num,EHex,8);      // "abc000000AA"</codeblock> </section>
       
   562 </conbody></concept>