[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 5 <title>.: jsolait :. | documentation | stringformat</title> 6 <link rel="stylesheet" type="text/css" href="./html.css" /> 7 <meta name="author" content="Jan-Klaas Kollhof" /> 8 <meta name="keywords" content="jsolait.stringformat" /> 9 </head> 10 <body> 11 <a name="top" id="top"></a> 12 <div class="navigationBar"><a href="./index.xhtml">documentation</a> | 13 stringformat</div> 14 <div class="menu"> 15 <ul></ul> 16 <div class="copyright">copyright © 2004, Jan-Klaas Kollhof</div> 17 </div> 18 <div class="content"> 19 <h1>Module stringformat</h1> 20 This module is automatically loaded with the main module.<br /> 21 It allows python like string formatting ("some text %s" % "something"). 22 Also similar to sprintf from C. 23 24 <div class="contentItem"><h2>globals:<a class="bttop" href="#top">▲</a></h2><div> 25 26 <h3>String::format()</h3><div class="indent"> 27 Formats a string replacing formatting specifiers with values provided as arguments<br /> 28 which are formatted according to the specifier.<br /> 29 This is an implementation of python's % operator for strings and is similar to sprintf from C.<br /> 30 Usage:<br /> 31 <code>resultString = formatString.format(value1, v2, ...);</code><br /> 32 <br /> 33 Each formatString can contain any number of formatting specifiers which are<br /> 34 replaced with the formated values.<br /> 35 <br /> 36 The following describes a format-specifier ([...] are optional): <br /> 37 <code>%[(key)][flag][sign][min][percision]typeOfValue</code> 38 <ul> 39 <li><b>(key)</b><br /> 40 If specified the 1st argument is treated as an object/associative array and the formating values <br /> 41 are retrieved from that object using the key.<br /> 42 </li> 43 <li><b>flag:</b><br /> 44 0 Use 0s for padding.<br /> 45 - Left justify result, padding it with spaces.<br /> 46 Use spaces for padding.<br /> 47 </li> 48 <li><b>sign:</b><br /> 49 + Numeric values will contain a +|- infront of the number.<br /> 50 </li> 51 <li><b>min:</b><br /> 52 l The string will be padded with the padding character until it has a minimum length of l. <br /> 53 </li> 54 <li><b>percision:</b><br /> 55 .x Where x is the percision for floating point numbers and the lenght for 0 padding for integers.<br /> 56 </li> 57 <li><b>typeOfValue:</b><br /> 58 d Signed integer decimal. <br /> 59 i Signed integer decimal. <br /> 60 b Unsigned binary. <br /> 61 o Unsigned octal. <br /> 62 u Unsigned decimal. <br /> 63 x Unsigned hexidecimal (lowercase). <br /> 64 X Unsigned hexidecimal (uppercase). <br /> 65 e Floating point exponential format (lowercase). <br /> 66 E Floating point exponential format (uppercase). <br /> 67 f Floating point decimal format. <br /> 68 F Floating point decimal format. <br /> 69 c Single character (accepts byte or single character string). <br /> 70 s String (converts any object using object.toString()). <br /> 71 </li> 72 </ul> 73 Examples:<br /> 74 "%02d".format(8) == "08"<br /> 75 "%05.2f".format(1.234) == "01.23"<br /> 76 "123 in binary is: %08b".format(123) == "123 in binary is: 01111011"<br /> 77 <br /> 78 <b></b> * Each parameter is treated as a formating value. <br /> 79 <br /> 80 </div> 81 <h3>String::pad(flag,len)</h3><div class="indent"> 82 Padds a String with a character to have a minimum length.<br /> 83 <br /> 84 <b>flag</b> "-": to padd with " " and left justify the string.<br /> 85 Other: the character to use for padding. <br /> 86 <b>len</b> The minimum length of the resulting string.<br /> 87 </div> 88 <h3>String.prototype.mul(c)</h3><div class="indent"> 89 Repeats a string.<br /> 90 <b>c</b> The count how often the string should be repeated.<br /> 91 </div> 92 </div></div> 93 </div> 94 </body> 95 </html>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |