1
<?xml version="1.0" encoding="ISO8859-1"?>
4
$Id: strings.xml,v 1.2 2004/09/01 19:06:19 michael Exp $
5
This file is part of the FPC documentation.
6
Copyright (C) 1997, by Michael Van Canneyt
8
The FPC documentation is free text; you can redistribute it and/or
9
modify it under the terms of the GNU Library General Public License as
10
published by the Free Software Foundation; either version 2 of the
11
License, or (at your option) any later version.
13
The FPC Documentation is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
Library General Public License for more details.
18
You should have received a copy of the GNU Library General Public
19
License along with the FPC documentation; see the file COPYING.LIB. If not,
20
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21
Boston, MA 02111-1307, USA.
24
<module name="strings">
25
<short>Null-terminated string (PChar) routines.</short>
26
<!-- \FPCexampledir{stringex -->
29
This chapter describes the <var>STRINGS</var> unit for Free Pascal.
30
This unit is system independent, and therefore works on all supported
35
<element name="StrAlloc">
36
<short>Allocate memory for a new null-terminated string on the heap</short>
38
<var>StrAlloc</var> reserves memory on the heap for a string with length <var>Len</var>,
39
terminating <var>#0</var> included, and returns a pointer to it.
42
If there is not enough memory, a run-time error occurs.
46
<link id="StrPCopy"/>.
50
<element name="StrCat">
51
<short>Concatenate 2 null-terminated strings.</short>
53
Attaches <var>Source</var> to <var>Dest</var> and returns <var>Dest</var>.
56
No length checking is performed.
61
<example file="stringex/ex11"/>
64
<element name="StrComp">
65
<short>Compare 2 null-terminated strings, case sensitive.</short>
68
Compares the null-terminated strings <var>S1</var> and <var>S2</var>.
72
<li> A negative <var>Longint</var> when <var>S1<S2</var>.
74
<li> 0 when <var>S1=S2</var>.
76
<li> A positive <var>Longint</var> when <var>S1>S2</var>.
80
For an example, see <link id="StrLComp"/>.
89
<link id="StrLIComp"/>
93
<element name="StrCopy">
94
<short>Copy a null-terminated string</short>
96
Copy the null terminated string in <var>Source</var> to <var>Dest</var>, and
97
returns a pointer to <var>Dest</var>. <var>Dest</var> needs enough room to contain
98
<var>Source</var>, i.e. <var>StrLen(Source)+1</var> bytes.
101
No length checking is performed.
104
<link id="StrPCopy"/>
105
<link id="StrLCopy"/>
106
<link id="StrECopy"/>
108
<example file="stringex/ex4"/>
112
<element name="StrDispose">
113
<short>disposes of a null-terminated string on the heap</short>
115
Removes the string in <var>P</var> from the heap and releases the memory.
123
<example file="stringex/ex17"/>
126
<element name="StrECopy">
127
<short>Copy a null-terminated string, return a pointer to the end.</short>
129
Copies the Null-terminated string in <var>Source</var> to <var>Dest</var>, and
130
returns a pointer to the end (i.e. the terminating Null-character) of the
134
No length checking is performed.
137
<link id="StrLCopy"/>
140
<example file="stringex/ex6"/>
143
<element name="StrEnd">
144
<short>Return a pointer to the end of a null-terminated string</short>
146
Returns a pointer to the end of <var>P</var>. (i.e. to the terminating
155
<example file="stringex/ex7"/>
158
<element name="StrIComp">
159
<short>Compare 2 null-terminated strings, case insensitive.</short>
162
Compares the null-terminated strings <var>S1</var> and <var>S2</var>, ignoring case.
166
<li> A negative <var>Longint</var> when <var>S1<S2</var>.
168
<li> 0 when <var>S1=S2</var>.
170
<li> A positive <var>Longint</var> when <var>S1>S2</var>.
178
<link id="StrLComp"/>
180
<link id="StrLIComp"/>
182
<example file="stringex/ex8"/>
185
<element name="StrLCat">
186
<short>Concatenate 2 null-terminated strings, with length boundary.</short>
188
Adds <var>MaxLen</var> characters from <var>Source</var> to <var>Dest</var>, and adds a
189
terminating null-character. Returns <var>Dest</var>.
197
<example file="stringex/ex12"/>
201
<element name="StrLComp">
202
<short>Compare limited number of characters of 2 null-terminated strings </short>
205
Compares maximum <var>L</var> characters of the null-terminated strings
206
<var>S1</var> and <var>S2</var>.
210
<li> A negative <var>Longint</var> when <var>S1<S2</var>.
212
<li> 0 when <var>S1=S2</var>.
214
<li> A positive <var>Longint</var> when <var>S1>S2</var>.
223
<link id="StrIComp"/>
224
<link id="StrLIComp"/>
226
<example file="stringex/ex8"/>
230
<element name="StrLCopy">
231
<short>Copy a null-terminated string, limited in length.</short>
233
Copies <var>MaxLen</var> characters from <var>Source</var> to <var>Dest</var>, and makes
234
<var>Dest</var> a null terminated string.
237
No length checking is performed.
241
<link id="StrECopy"/>
243
<example file="stringex/ex5"/>
247
<element name="StrLen">
248
<short>Length of a null-terminated string.</short>
250
Returns the length of the null-terminated string <var>P</var>.
258
<example file="stringex/ex1"/>
262
<element name="StrLIComp">
263
<short>Compare limited number of characters in 2 null-terminated strings,
264
ignoring case.</short>
267
Compares maximum <var>L</var> characters of the null-terminated strings <var>S1</var>
268
and <var>S2</var>, ignoring case.
272
<li> A negative <var>Longint</var> when <var>S1<S2</var>.
274
<li> 0 when <var>S1=S2</var>.
276
<li> A positive <var>Longint</var> when <var>S1>S2</var>.
280
For an example, see <link id="StrIComp"/>
287
<link id="StrLComp"/>
289
<link id="StrIComp"/>
294
<element name="StrLower">
295
<short>Convert null-terminated string to all-lowercase.</short>
297
Converts <var>P</var> to an all-lowercase string. Returns <var>P</var>.
303
<link id="StrUpper"/>
305
<example file="stringex/ex14"/>
309
<element name="StrMove">
310
<short>Move a null-terminated string to new location.</short>
312
Copies <var>MaxLen</var> characters from <var>Source</var> to <var>Dest</var>. No
313
terminating null-character is copied.
314
Returns <var>Dest</var>
320
<link id="StrLCopy"/>
323
<example file="stringex/ex10"/>
327
<element name="StrNew">
328
<short>Allocate room for new null-terminated string.</short>
330
Copies <var>P</var> to the Heap, and returns a pointer to the copy.
333
Returns <var>Nil</var> if no memory was available for the copy.
337
<link id="StrDispose"/>
339
<example file="stringex/ex16"/>
342
<element name="StrPas">
343
<short>Convert a null-terminated string to a shortstring.</short>
345
Converts a null terminated string in <var>P</var> to a Pascal string, and returns
346
this string. The string is truncated at 255 characters.
352
<link id="StrPCopy"/>
354
<example file="stringex/ex3"/>
358
<element name="StrPCopy">
359
<short>Copy a pascal string to a null-terminated string</short>
361
Converts the Pascal string in <var>Source</var> to a Null-terminated
362
string, and copies it to <var>Dest</var>. <var>Dest</var> needs enough room to contain
363
the string <var>Source</var>, i.e. <var>Length(Source)+1</var> bytes.
366
No length checking is performed.
371
<example file="stringex/ex2"/>
375
<element name="StrPos">
376
<short>Search for a null-terminated substring in a null-terminated
379
Returns a pointer to the first occurrence of <var>S2</var> in <var>S1</var>.
380
If <var>S2</var> does not occur in <var>S1</var>, returns <var>Nil</var>.
387
<link id="StrRScan"/>
389
<example file="stringex/ex15"/>
392
<element name="StrRScan">
393
<short>Find last occurrence of a character in a null-terminated string.</short>
396
Returns a pointer to the last occurrence of the character <var>C</var> in the
397
null-terminated string <var>P</var>. If <var>C</var> does not occur, returns
401
For an example, see <link id="StrScan"/>.
416
<element name="StrScan">
417
<short>Find first occurrence of a character in a null-terminated string.</short>
419
Returns a pointer to the first occurrence of the character <var>C</var> in the
420
null-terminated string <var>P</var>. If <var>C</var> does not occur, returns
427
<link id="StrRScan"/>
430
<example file="stringex/ex13"/>
434
<element name="StrUpper">
435
<short>Convert null-terminated string to all-uppercase</short>
438
Converts <var>P</var> to an all-uppercase string. Returns <var>P</var>.
441
For an example, see <link id="StrLower"/>
448
<link id="StrLower"/>
454
</fpdoc-descriptions>