mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-17 20:21:18 +01:00
96 lines
5.6 KiB
HTML
96 lines
5.6 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
<title>.: jsolait :. | documentation | stringformat</title>
|
|
<link rel="stylesheet" type="text/css" href="./html.css" />
|
|
<meta name="author" content="Jan-Klaas Kollhof" />
|
|
<meta name="keywords" content="jsolait.stringformat" />
|
|
</head>
|
|
<body>
|
|
<a name="top" id="top"></a>
|
|
<div class="navigationBar"><a href="./index.xhtml">documentation</a> |
|
|
stringformat</div>
|
|
<div class="menu">
|
|
<ul></ul>
|
|
<div class="copyright">copyright © 2004, Jan-Klaas Kollhof</div>
|
|
</div>
|
|
<div class="content">
|
|
<h1>Module stringformat</h1>
|
|
This module is automatically loaded with the main module.<br />
|
|
It allows python like string formatting ("some text %s" % "something").
|
|
Also similar to sprintf from C.
|
|
|
|
<div class="contentItem"><h2>globals:<a class="bttop" href="#top">▲</a></h2><div>
|
|
|
|
<h3>String::format()</h3><div class="indent">
|
|
Formats a string replacing formatting specifiers with values provided as arguments<br />
|
|
which are formatted according to the specifier.<br />
|
|
This is an implementation of python's % operator for strings and is similar to sprintf from C.<br />
|
|
Usage:<br />
|
|
<code>resultString = formatString.format(value1, v2, ...);</code><br />
|
|
<br />
|
|
Each formatString can contain any number of formatting specifiers which are<br />
|
|
replaced with the formated values.<br />
|
|
<br />
|
|
The following describes a format-specifier ([...] are optional): <br />
|
|
<code>%[(key)][flag][sign][min][percision]typeOfValue</code>
|
|
<ul>
|
|
<li><b>(key)</b><br />
|
|
If specified the 1st argument is treated as an object/associative array and the formating values <br />
|
|
are retrieved from that object using the key.<br />
|
|
</li>
|
|
<li><b>flag:</b><br />
|
|
0 Use 0s for padding.<br />
|
|
- Left justify result, padding it with spaces.<br />
|
|
Use spaces for padding.<br />
|
|
</li>
|
|
<li><b>sign:</b><br />
|
|
+ Numeric values will contain a +|- infront of the number.<br />
|
|
</li>
|
|
<li><b>min:</b><br />
|
|
l The string will be padded with the padding character until it has a minimum length of l. <br />
|
|
</li>
|
|
<li><b>percision:</b><br />
|
|
.x Where x is the percision for floating point numbers and the lenght for 0 padding for integers.<br />
|
|
</li>
|
|
<li><b>typeOfValue:</b><br />
|
|
d Signed integer decimal. <br />
|
|
i Signed integer decimal. <br />
|
|
b Unsigned binary. <br />
|
|
o Unsigned octal. <br />
|
|
u Unsigned decimal. <br />
|
|
x Unsigned hexidecimal (lowercase). <br />
|
|
X Unsigned hexidecimal (uppercase). <br />
|
|
e Floating point exponential format (lowercase). <br />
|
|
E Floating point exponential format (uppercase). <br />
|
|
f Floating point decimal format. <br />
|
|
F Floating point decimal format. <br />
|
|
c Single character (accepts byte or single character string). <br />
|
|
s String (converts any object using object.toString()). <br />
|
|
</li>
|
|
</ul>
|
|
Examples:<br />
|
|
"%02d".format(8) == "08"<br />
|
|
"%05.2f".format(1.234) == "01.23"<br />
|
|
"123 in binary is: %08b".format(123) == "123 in binary is: 01111011"<br />
|
|
<br />
|
|
<b></b> * Each parameter is treated as a formating value. <br />
|
|
<br />
|
|
</div>
|
|
<h3>String::pad(flag,len)</h3><div class="indent">
|
|
Padds a String with a character to have a minimum length.<br />
|
|
<br />
|
|
<b>flag</b> "-": to padd with " " and left justify the string.<br />
|
|
Other: the character to use for padding. <br />
|
|
<b>len</b> The minimum length of the resulting string.<br />
|
|
</div>
|
|
<h3>String.prototype.mul(c)</h3><div class="indent">
|
|
Repeats a string.<br />
|
|
<b>c</b> The count how often the string should be repeated.<br />
|
|
</div>
|
|
</div></div>
|
|
</div>
|
|
</body>
|
|
</html>
|