This repository was archived by the owner on Apr 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdevelopment_javascript_String.html
More file actions
278 lines (226 loc) · 7.79 KB
/
development_javascript_String.html
File metadata and controls
278 lines (226 loc) · 7.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mobile Widgets</title>
<link rel="stylesheet" href="style/style.css" />
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
<script type="text/javascript" src="js/StructureElts.js"></script>
<script type="text/javascript" src="js/Structure.js"></script>
<script type="text/javascript" src="js/DocElements.js"></script>
</head>
<body>
<script type="text/javascript">
<!--
idCurrentPage = "development_javascript_String";
beginPage();
//-->
</script>
<h1 class="title">String Javascript library</h1>
<script type="text/javascript">
<!--
addIndex();
//-->
</script>
<script type="text/javascript">addTitle("Description", 1);</script>
<p>
The String class provides means to manipulate arrays of chars (Strings)
</p>
<br/>
<script type="text/javascript">addTitle("Since", 1);</script>
<h2>1.4.1</h2>
<p>
New methods: <b>join()</b>, <b>replace()</b>, <b>split()</b>.
</p>
<br/>
<script type="text/javascript">addTitle("Methods", 1);</script>
<p>
<b>int charAt (String s, int i)</b>:<br/>
Returns the ASCII/UTF-8 code of the character at index <b>i</b> inside string <b>s</b>.<br/>
Example:
</p>
<textarea wrap="off" readonly="readonly" rows="1" cols="80">String.charAt ("ABCD", 2); // 67</textarea>
<br/>
<p>
<b>String decodeBase64 (String s)</b>:<br/>
Return a string decoded in Base 64 from <b>s</b>.
</p>
<p class="note warning">
<b>Warning:</b><br/>This method might not be available (requires MM.base64).
</p>
<p>
<b>String decodeUrl (String s)</b>:<br/>
Returns an URL decoded version of the string <b>s</b>.<br/>
Example:
</p>
<textarea wrap="off" readonly="readonly" rows="2" cols="80">
String.makeAscii ("http%3A//myserver.org/myscript%3Fparam1%3Darg1%26param2%3Darg2");
// "http://myserver.org/myscript?param1=arg1&param2=arg2"
</textarea>
<br/>
<p>
<b>String encodeBase64 (String s)</b>:<br/>
Return a string encoded in Base 64 from <b>s</b>.
</p>
<p class="note warning">
<b>Warning:</b><br/>This method might not be available (requires MM.base64).
</p>
<p>
<b>String encodeUrl (String s)</b>:<br/>
Returns an URL encoded version of the string <b>s</b>.<br/>
Example:
</p>
<textarea wrap="off" readonly="readonly" rows="2" cols="80">
String.makeAscii ("http://myserver.org/myscript?param1=arg1&param2=arg2");
// "http%3A//myserver.org/myscript%3Fparam1%3Darg1%26param2%3Darg2"
</textarea>
<br/>
<p>
<b>bool endsWith (String s, String t)</b>:<br/>
Returns true if <b>s</b> ends with <b>t</b>.<br/>
Example:
</p>
<textarea wrap="off" readonly="readonly" rows="1" cols="80">
String.endsWith ("ABCDEF", "DEF"); // true
</textarea>
<br/>
<p>
<b>int height (Node fontStyle)</b>:<br/>
Returns the height (in pixels) of the string rendered using the specified <b>fontstyle</b> node.
</p>
<p class="note warning">
<b>Warning:</b><br/>The <b>fontsyle</b> node must not be switched !
</p>
<p>
<b>int indexOf (String s, String char, int index)</b>:<br/>
Returns the first position of <b>char</b> in <b>s</b>, starting at <b>index</b>.<br/>
Example:
</p>
<textarea wrap="off" readonly="readonly" rows="1" cols="80">
String.indexOf ('ABCDEFABCDEF', 'A', 2); // 6
</textarea>
<br/>
<p>
<b>String join (MFString orig, char sep, int max)</b>:<br/>
Returns joined strings from <b>orig</b> using the optional <b>sep</b> char. Joining can be limited to the first <b>max</b> strings for <b>orig</b>.<br/>
Returns empty string on error.<br/>
<b>Since 1.4.1</b>
</p>
<p>
<b>int lastIndexOf (String s, int char, int index)</b>:<br/>
Returns the last position of <b>char</b> in <b>s</b>, starting at <b>index</b>.<br/>
Example:
</p>
<textarea wrap="off" readonly="readonly" rows="1" cols="80">
String.lastIndexOf ('ABCDEFABCDEF', 'F', 10); // 5
</textarea>
<br/>
<p>
<b>int length (String s)</b>:<br/>
Returns the number of chars in <b>s</b>.<br/>
Example:
</p>
<textarea wrap="off" readonly="readonly" rows="1" cols="80">String.length ("ABCD"); // 4</textarea>
<br/>
<p>
<b>String makeAscii (int i)</b>:<br/>
Returns a string with a single char made that has the parameter <b>i</b> as ascii code.<br/>
Example:
</p>
<textarea wrap="off" readonly="readonly" rows="1" cols="80">String.makeAscii (65); // "A"</textarea>
<br/>
<p>
<b>String replace (String s, String token, String replace)</b>:<br/>
Returns a string where all sub-strings matching <b>token</b> in <b>s</b> are replaced by the <b>replace</b> string.<br/>
<b>Since 1.4.1</b>
</p>
<p>
<b>int split (string orig, MFString dest, [char separator])</b>:<br/>
Split <b>orig</b> in tokens to fill the <b>dest</b> array.<br/>
If <b>separator</b> is not defined, comma ',' will be used as the default separator.<br/>
If no <b>sep</b> is found in <b>orig</b>, the first slot of <b>dest</b> will contain <b>orig</b>.<br/>
Returns the number of tokens or 0 on error.<br/>
<b>Since 1.4.1</b>
</p>
<p>
<b>bool startsWith (String s, string t)</b>:<br/>
Returns true if <b>s</b> starts with <b>t</b>.<br/>
Example:
</p>
<textarea wrap="off" readonly="readonly" rows="1" cols="80">String.startsWith ("ABCDEF", "AB"); // true</textarea>
<br/>
<p>
<b>int strIndexOf (String s, String t, int index)</b>:<br/>
Returns the first position of <b>t</b> in <b>s</b>, starting at <b>index</b>.<br/>
Example:
</p>
<textarea wrap="off" readonly="readonly" rows="1" cols="80">String.strIndexOf ("ABCDEFABCDE", "CD", 5); // 8</textarea>
<br/>
<p>
<b>String substring (String s, int start, int end)</b>:<br/>
Returns the substring of <b>s</b>, starting at <b>start</b> and ending at <b>end</b>.<br/>
If <b>end</b> < 0, return up to the end of the string.<br/>
Example:
</p>
<textarea wrap="off" readonly="readonly" rows="1" cols="80">String.substring ("ABCDEF", 2, 4); // "CDE"</textarea>
<br/>
<p>
<b>float toFloat (String s)</b>:<br/>
Returns the float that can be converted from <b>s</b>.<br/>
Example:
</p>
<textarea wrap="off" readonly="readonly" rows="1" cols="80">String.toFloat ("12.345"); // 12.345</textarea>
<br/>
<p>
<b>int toInt (String s)</b>:<br/>
Returns the integer that can be converted from <b>s</b>.<br/>
Example:
</p>
<textarea wrap="off" readonly="readonly" rows="1" cols="80">String.toInt ("12345"); // 12345</textarea>
<br/>
<p>
<b>String toLower (String s)</b>:<br/>
Returns the lower case version of <b>s</b>.<br/>
Example:
</p>
<textarea wrap="off" readonly="readonly" rows="1" cols="80">String.toLower ("AbCD"); // abcd</textarea>
<br/>
<p>
<b>String toUpper (String s)</b>:<br/>
Returns the upper case version of <b>s</b>.<br/>
Example:
</p>
<textarea wrap="off" readonly="readonly" rows="1" cols="80">String.toUpper ("aBcd"); // ABCD</textarea>
<br/>
<p>
<b>String trim (String s)</b>:<br/>
Returns the trimmed version of <b>s</b> (space removed at both ends).<br/>
Example:
</p>
<textarea wrap="off" readonly="readonly" rows="1" cols="80">String.trim (" hello "); // "hello"</textarea>
<br/>
<p>
<b>int width (String s, Node fontStyle)</b>:<br/>
Returns the width (in pixels) of the string rendered using the specified <b>fontstyle</b> node.
</p>
<p class="note warning">
<b>Warning:</b><br/>The <b>fontsyle</b> node must not be switched !
</p>
<p class="note warning">
<b>Warning:</b><br/>The <b>fontsyle</b> node must be defined, otherwise the string itself is returned !
</p>
<br/>
<script type="text/javascript">
<!--
addBackPageNavigator('widgets_development_javascript_ref', '');
//-->
</script>
<script type="text/javascript">
<!--
endPage();
//-->
</script>
</body>
</html>