OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / CELLLINUX64 / util / CELLLINUX64 / man / man3 / Tcl_GetCharLength.3
1 '\"
2 '\" Copyright (c) 1994-1997 Sun Microsystems, Inc.
3 '\"
4 '\" See the file "license.terms" for information on usage and redistribution
5 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
6 '\" 
7 '\" RCS: @(#) $Id: StringObj.3,v 1.13.2.1 2003/07/18 16:56:24 dgp Exp $
8 '\" 
9 '\" The definitions below are for supplemental macros used in Tcl/Tk
10 '\" manual entries.
11 '\"
12 '\" .AP type name in/out ?indent?
13 '\"     Start paragraph describing an argument to a library procedure.
14 '\"     type is type of argument (int, etc.), in/out is either "in", "out",
15 '\"     or "in/out" to describe whether procedure reads or modifies arg,
16 '\"     and indent is equivalent to second arg of .IP (shouldn't ever be
17 '\"     needed;  use .AS below instead)
18 '\"
19 '\" .AS ?type? ?name?
20 '\"     Give maximum sizes of arguments for setting tab stops.  Type and
21 '\"     name are examples of largest possible arguments that will be passed
22 '\"     to .AP later.  If args are omitted, default tab stops are used.
23 '\"
24 '\" .BS
25 '\"     Start box enclosure.  From here until next .BE, everything will be
26 '\"     enclosed in one large box.
27 '\"
28 '\" .BE
29 '\"     End of box enclosure.
30 '\"
31 '\" .CS
32 '\"     Begin code excerpt.
33 '\"
34 '\" .CE
35 '\"     End code excerpt.
36 '\"
37 '\" .VS ?version? ?br?
38 '\"     Begin vertical sidebar, for use in marking newly-changed parts
39 '\"     of man pages.  The first argument is ignored and used for recording
40 '\"     the version when the .VS was added, so that the sidebars can be
41 '\"     found and removed when they reach a certain age.  If another argument
42 '\"     is present, then a line break is forced before starting the sidebar.
43 '\"
44 '\" .VE
45 '\"     End of vertical sidebar.
46 '\"
47 '\" .DS
48 '\"     Begin an indented unfilled display.
49 '\"
50 '\" .DE
51 '\"     End of indented unfilled display.
52 '\"
53 '\" .SO
54 '\"     Start of list of standard options for a Tk widget.  The
55 '\"     options follow on successive lines, in four columns separated
56 '\"     by tabs.
57 '\"
58 '\" .SE
59 '\"     End of list of standard options for a Tk widget.
60 '\"
61 '\" .OP cmdName dbName dbClass
62 '\"     Start of description of a specific option.  cmdName gives the
63 '\"     option's name as specified in the class command, dbName gives
64 '\"     the option's name in the option database, and dbClass gives
65 '\"     the option's class in the option database.
66 '\"
67 '\" .UL arg1 arg2
68 '\"     Print arg1 underlined, then print arg2 normally.
69 '\"
70 '\" RCS: @(#) $Id: man.macros,v 1.4 2000/08/25 06:18:32 ericm Exp $
71 '\"
72 '\"     # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
73 .if t .wh -1.3i ^B
74 .nr ^l \n(.l
75 .ad b
76 '\"     # Start an argument description
77 .de AP
78 .ie !"\\$4"" .TP \\$4
79 .el \{\
80 .   ie !"\\$2"" .TP \\n()Cu
81 .   el          .TP 15
82 .\}
83 .ta \\n()Au \\n()Bu
84 .ie !"\\$3"" \{\
85 \&\\$1  \\fI\\$2\\fP    (\\$3)
86 .\".b
87 .\}
88 .el \{\
89 .br
90 .ie !"\\$2"" \{\
91 \&\\$1  \\fI\\$2\\fP
92 .\}
93 .el \{\
94 \&\\fI\\$1\\fP
95 .\}
96 .\}
97 ..
98 '\"     # define tabbing values for .AP
99 .de AS
100 .nr )A 10n
101 .if !"\\$1"" .nr )A \\w'\\$1'u+3n
102 .nr )B \\n()Au+15n
103 .\"
104 .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
105 .nr )C \\n()Bu+\\w'(in/out)'u+2n
106 ..
107 .AS Tcl_Interp Tcl_CreateInterp in/out
108 '\"     # BS - start boxed text
109 '\"     # ^y = starting y location
110 '\"     # ^b = 1
111 .de BS
112 .br
113 .mk ^y
114 .nr ^b 1u
115 .if n .nf
116 .if n .ti 0
117 .if n \l'\\n(.lu\(ul'
118 .if n .fi
119 ..
120 '\"     # BE - end boxed text (draw box now)
121 .de BE
122 .nf
123 .ti 0
124 .mk ^t
125 .ie n \l'\\n(^lu\(ul'
126 .el \{\
127 .\"     Draw four-sided box normally, but don't draw top of
128 .\"     box if the box started on an earlier page.
129 .ie !\\n(^b-1 \{\
130 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
131 .\}
132 .el \}\
133 \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
134 .\}
135 .\}
136 .fi
137 .br
138 .nr ^b 0
139 ..
140 '\"     # VS - start vertical sidebar
141 '\"     # ^Y = starting y location
142 '\"     # ^v = 1 (for troff;  for nroff this doesn't matter)
143 .de VS
144 .if !"\\$2"" .br
145 .mk ^Y
146 .ie n 'mc \s12\(br\s0
147 .el .nr ^v 1u
148 ..
149 '\"     # VE - end of vertical sidebar
150 .de VE
151 .ie n 'mc
152 .el \{\
153 .ev 2
154 .nf
155 .ti 0
156 .mk ^t
157 \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
158 .sp -1
159 .fi
160 .ev
161 .\}
162 .nr ^v 0
163 ..
164 '\"     # Special macro to handle page bottom:  finish off current
165 '\"     # box/sidebar if in box/sidebar mode, then invoked standard
166 '\"     # page bottom macro.
167 .de ^B
168 .ev 2
169 'ti 0
170 'nf
171 .mk ^t
172 .if \\n(^b \{\
173 .\"     Draw three-sided box if this is the box's first page,
174 .\"     draw two sides but no top otherwise.
175 .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
176 .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
177 .\}
178 .if \\n(^v \{\
179 .nr ^x \\n(^tu+1v-\\n(^Yu
180 \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
181 .\}
182 .bp
183 'fi
184 .ev
185 .if \\n(^b \{\
186 .mk ^y
187 .nr ^b 2
188 .\}
189 .if \\n(^v \{\
190 .mk ^Y
191 .\}
192 ..
193 '\"     # DS - begin display
194 .de DS
195 .RS
196 .nf
197 .sp
198 ..
199 '\"     # DE - end display
200 .de DE
201 .fi
202 .RE
203 .sp
204 ..
205 '\"     # SO - start of list of standard options
206 .de SO
207 .SH "STANDARD OPTIONS"
208 .LP
209 .nf
210 .ta 5.5c 11c
211 .ft B
212 ..
213 '\"     # SE - end of list of standard options
214 .de SE
215 .fi
216 .ft R
217 .LP
218 See the \\fBoptions\\fR manual entry for details on the standard options.
219 ..
220 '\"     # OP - start of full description for a single option
221 .de OP
222 .LP
223 .nf
224 .ta 4c
225 Command-Line Name:      \\fB\\$1\\fR
226 Database Name:  \\fB\\$2\\fR
227 Database Class: \\fB\\$3\\fR
228 .fi
229 .IP
230 ..
231 '\"     # CS - begin code excerpt
232 .de CS
233 .RS
234 .nf
235 .ta .25i .5i .75i 1i
236 ..
237 '\"     # CE - end code excerpt
238 .de CE
239 .fi
240 .RE
241 ..
242 .de UL
243 \\$1\l'|0\(ul'\\$2
244 ..
245 .TH Tcl_StringObj 3 8.1 Tcl "Tcl Library Procedures"
246 .BS
247 .SH NAME
248 Tcl_NewStringObj, Tcl_NewUnicodeObj, Tcl_SetStringObj, Tcl_SetUnicodeObj, Tcl_GetStringFromObj, Tcl_GetString, Tcl_GetUnicodeFromObj, Tcl_GetUnicode, Tcl_GetUniChar, Tcl_GetCharLength, Tcl_GetRange, Tcl_AppendToObj, Tcl_AppendUnicodeToObj, Tcl_AppendStringsToObj, Tcl_AppendStringsToObjVA, Tcl_AppendObjToObj, Tcl_SetObjLength, Tcl_ConcatObj, Tcl_AttemptSetObjLength \- manipulate Tcl objects as strings
249 .SH SYNOPSIS
250 .nf
251 \fB#include <tcl.h>\fR
252 .sp
253 Tcl_Obj *
254 \fBTcl_NewStringObj\fR(\fIbytes, length\fR)
255 .sp
256 Tcl_Obj *
257 \fBTcl_NewUnicodeObj\fR(\fIunicode, numChars\fR)
258 .sp
259 void
260 \fBTcl_SetStringObj\fR(\fIobjPtr, bytes, length\fR)
261 .sp
262 void
263 \fBTcl_SetUnicodeObj\fR(\fIobjPtr, unicode, numChars\fR)
264 .sp
265 char *
266 \fBTcl_GetStringFromObj\fR(\fIobjPtr, lengthPtr\fR)
267 .sp
268 char *
269 \fBTcl_GetString\fR(\fIobjPtr\fR)
270 .sp
271 Tcl_UniChar *
272 \fBTcl_GetUnicodeFromObj\fR(\fIobjPtr, lengthPtr\fR)
273 .sp
274 Tcl_UniChar *
275 \fBTcl_GetUnicode\fR(\fIobjPtr\fR)
276 .sp
277 Tcl_UniChar
278 \fBTcl_GetUniChar\fR(\fIobjPtr, index\fR)
279 .sp
280 int
281 \fBTcl_GetCharLength\fR(\fIobjPtr\fR)
282 .sp
283 Tcl_Obj *
284 \fBTcl_GetRange\fR(\fIobjPtr, first, last\fR)
285 .sp
286 void
287 \fBTcl_AppendToObj\fR(\fIobjPtr, bytes, length\fR)
288 .sp
289 void
290 \fBTcl_AppendUnicodeToObj\fR(\fIobjPtr, unicode, numChars\fR)
291 .sp
292 void
293 \fBTcl_AppendObjToObj\fR(\fIobjPtr, appendObjPtr\fR)
294 .sp
295 void
296 \fBTcl_AppendStringsToObj\fR(\fIobjPtr, string, string, ... \fB(char *) NULL\fR)
297 .sp
298 void
299 \fBTcl_AppendStringsToObjVA\fR(\fIobjPtr, argList\fR)
300 .sp
301 void
302 \fBTcl_SetObjLength\fR(\fIobjPtr, newLength\fR)
303 .sp
304 int
305 \fBTcl_AttemptSetObjLength\fR(\fIobjPtr, newLength\fR)
306 .sp
307 Tcl_Obj *
308 \fBTcl_ConcatObj\fR(\fIobjc, objv\fR)
309 .SH ARGUMENTS
310 .AS "CONST Tcl_UniChar" *appendObjPtr in/out
311 .AP "CONST char" *bytes in
312 .VS 8.1
313 Points to the first byte of an array of UTF-8-encoded bytes
314 used to set or append to a string object.
315 This byte array should not contain embedded null bytes
316 unless \fIlength\fR is negative.  (Applications needing null bytes
317 should represent them as the two-byte sequence \fI\\700\\600\fR, use
318 \fBTcl_ExternalToUtf\fR to convert, or \fBTcl_NewByteArrayObj\fR if
319 the string is a collection of uninterpreted bytes.)
320 .VE 8.1
321 .AP int length in
322 The number of bytes to copy from \fIbytes\fR when
323 initializing, setting, or appending to a string object.
324 If negative, all bytes up to the first null are used.
325 .AP "CONST Tcl_UniChar" *unicode in
326 Points to the first byte of an array of Unicode characters
327 used to set or append to a string object.
328 This byte array may contain embedded null characters
329 unless \fInumChars\fR is negative.
330 .AP int numChars in
331 The number of Unicode characters to copy from \fIunicode\fR when
332 initializing, setting, or appending to a string object.
333 If negative, all characters up to the first null character are used.
334 .AP int index in
335 The index of the Unicode character to return.
336 .AP int first in
337 The index of the first Unicode character in the Unicode range to be
338 returned as a new object.
339 .AP int last in
340 The index of the last Unicode character in the Unicode range to be
341 returned as a new object.
342 .AP Tcl_Obj *objPtr in/out
343 Points to an object to manipulate.
344 .AP Tcl_Obj *appendObjPtr in
345 The object to append to \fIobjPtr\fR in \fBTcl_AppendObjToObj\fR.
346 .AP int *lengthPtr out
347 If non-NULL, the location where \fBTcl_GetStringFromObj\fR will store
348 the the length of an object's string representation.
349 .AP "CONST char" *string in
350 Null-terminated string value to append to \fIobjPtr\fR.
351 .AP va_list argList in
352 An argument list which must have been initialised using
353 \fBTCL_VARARGS_START\fR, and cleared using \fBva_end\fR.
354 .AP int newLength in
355 New length for the string value of \fIobjPtr\fR, not including the
356 final null character.
357 .AP int objc in
358 The number of elements to concatenate.
359 .AP Tcl_Obj *objv[] in
360 The array of objects to concatenate.
361 .BE
362
363 .SH DESCRIPTION
364 .PP
365 The procedures described in this manual entry allow Tcl objects to
366 be manipulated as string values.  They use the internal representation
367 of the object to store additional information to make the string
368 manipulations more efficient.  In particular, they make a series of
369 append operations efficient by allocating extra storage space for the
370 string so that it doesn't have to be copied for each append.
371 Also, indexing and length computations are optimized because the
372 Unicode string representation is calculated and cached as needed.
373 When using the \fBTcl_Append*\fR family of functions where the
374 interpreter's result is the object being appended to, it is important
375 to call Tcl_ResetResult first to ensure you are not unintentionally
376 appending to existing data in the result object.
377 .PP
378 \fBTcl_NewStringObj\fR and \fBTcl_SetStringObj\fR create a new object
379 or modify an existing object to hold a copy of the string given by
380 \fIbytes\fR and \fIlength\fR.  \fBTcl_NewUnicodeObj\fR and
381 \fBTcl_SetUnicodeObj\fR create a new object or modify an existing
382 object to hold a copy of the Unicode string given by \fIunicode\fR and
383 \fInumChars\fR.  \fBTcl_NewStringObj\fR and \fBTcl_NewUnicodeObj\fR
384 return a pointer to a newly created object with reference count zero.
385 All four procedures set the object to hold a copy of the specified
386 string.  \fBTcl_SetStringObj\fR and \fBTcl_SetUnicodeObj\fR free any
387 old string representation as well as any old internal representation
388 of the object.
389 .PP
390 \fBTcl_GetStringFromObj\fR and \fBTcl_GetString\fR return an object's
391 string representation.  This is given by the returned byte pointer and
392 (for \fBTcl_GetStringFromObj\fR) length, which is stored in
393 \fIlengthPtr\fR if it is non-NULL.  If the object's UTF string
394 representation is invalid (its byte pointer is NULL), the string
395 representation is regenerated from the object's internal
396 representation.  The storage referenced by the returned byte pointer
397 is owned by the object manager.  It is passed back as a writable
398 pointer so that extension author creating their own \fBTcl_ObjType\fR
399 will be able to modify the string representation within the
400 \fBTcl_UpdateStringProc\fR of their \fBTcl_ObjType\fR.  Except for that
401 limited purpose, the pointer returned by \fBTcl_GetStringFromObj\fR
402 or \fBTcl_GetString\fR should be treated as read-only.  It is
403 recommended that this pointer be assigned to a (CONST char *) variable.
404 Even in the limited situations where writing to this pointer is
405 acceptable, one should take care to respect the copy-on-write
406 semantics required by \fBTcl_Obj\fR's, with appropriate calls
407 to \fBTcl_IsShared\fR and \fBTcl_DuplicateObj\fR prior to any
408 in-place modification of the string representation.
409 The procedure \fBTcl_GetString\fR is used in the common case
410 where the caller does not need the length of the string
411 representation.
412 .PP
413 \fBTcl_GetUnicodeFromObj\fR and \fBTcl_GetUnicode\fR return an object's
414 value as a Unicode string.  This is given by the returned pointer and
415 (for \fBTcl_GetUnicodeFromObj\fR) length, which is stored in
416 \fIlengthPtr\fR if it is non-NULL.  The storage referenced by the returned
417 byte pointer is owned by the object manager and should not be modified by
418 the caller.  The procedure \fBTcl_GetUnicode\fR is used in the common case
419 where the caller does not need the length of the unicode string
420 representation.
421 .PP
422 \fBTcl_GetUniChar\fR returns the \fIindex\fR'th character in the
423 object's Unicode representation.
424 .PP
425 \fBTcl_GetRange\fR returns a newly created object comprised of the
426 characters between \fIfirst\fR and \fIlast\fR (inclusive) in the
427 object's Unicode representation.  If the object's Unicode
428 representation is invalid, the Unicode representation is regenerated
429 from the object's string representation.
430 .PP
431 \fBTcl_GetCharLength\fR returns the number of characters (as opposed
432 to bytes) in the string object.
433 .PP
434 \fBTcl_AppendToObj\fR appends the data given by \fIbytes\fR and
435 \fIlength\fR to the string representation of the object specified by
436 \fIobjPtr\fR.  If the object has an invalid string representation,
437 then an attempt is made to convert \fIbytes\fR is to the Unicode
438 format.  If the conversion is successful, then the converted form of
439 \fIbytes\fR is appended to the object's Unicode representation.
440 Otherwise, the object's Unicode representation is invalidated and
441 converted to the UTF format, and \fIbytes\fR is appended to the
442 object's new string representation.
443 .PP
444 \fBTcl_AppendUnicodeToObj\fR appends the Unicode string given by
445 \fIunicode\fR and \fInumChars\fR to the object specified by
446 \fIobjPtr\fR.  If the object has an invalid Unicode representation,
447 then \fIunicode\fR is converted to the UTF format and appended to the
448 object's string representation.  Appends are optimized to handle
449 repeated appends relatively efficiently (it overallocates the string
450 or Unicode space to avoid repeated reallocations and copies of
451 object's string value).
452 .PP
453 \fBTcl_AppendObjToObj\fR is similar to \fBTcl_AppendToObj\fR, but it
454 appends the string or Unicode value (whichever exists and is best
455 suited to be appended to \fIobjPtr\fR) of \fIappendObjPtr\fR to
456 \fIobjPtr\fR.
457 .PP
458 \fBTcl_AppendStringsToObj\fR is similar to \fBTcl_AppendToObj\fR
459 except that it can be passed more than one value to append and
460 each value must be a null-terminated string (i.e. none of the
461 values may contain internal null characters).  Any number of
462 \fIstring\fR arguments may be provided, but the last argument
463 must be a NULL pointer to indicate the end of the list.
464 .PP
465 \fBTcl_AppendStringsToObjVA\fR is the same as \fBTcl_AppendStringsToObj\fR
466 except that instead of taking a variable number of arguments it takes an
467 argument list.
468 .PP
469 The \fBTcl_SetObjLength\fR procedure changes the length of the
470 string value of its \fIobjPtr\fR argument.  If the \fInewLength\fR
471 argument is greater than the space allocated for the object's
472 string, then the string space is reallocated and the old value
473 is copied to the new space; the bytes between the old length of
474 the string and the new length may have arbitrary values.
475 If the \fInewLength\fR argument is less than the current length
476 of the object's string, with \fIobjPtr->length\fR is reduced without
477 reallocating the string space; the original allocated size for the
478 string is recorded in the object, so that the string length can be
479 enlarged in a subsequent call to \fBTcl_SetObjLength\fR without
480 reallocating storage.  In all cases \fBTcl_SetObjLength\fR leaves
481 a null character at \fIobjPtr->bytes[newLength]\fR.
482 .PP
483 \fBTcl_AttemptSetObjLength\fR is identical in function to
484 \fBTcl_SetObjLength\fR except that if sufficient memory to satisfy the
485 request cannot be allocated, it does not cause the Tcl interpreter to
486 \fBpanic\fR.  Thus, if \fInewLength\fR is greater than the space
487 allocated for the object's string, and there is not enough memory
488 available to satisfy the request, \fBTcl_AttemptSetObjLength\fR will take
489 no action and return 0 to indicate failure.  If there is enough memory
490 to satisfy the request, \fBTcl_AttemptSetObjLength\fR behaves just like
491 \fBTcl_SetObjLength\fR and returns 1 to indicate success.
492 .PP
493 The \fBTcl_ConcatObj\fR function returns a new string object whose
494 value is the space-separated concatenation of the string
495 representations of all of the objects in the \fIobjv\fR
496 array. \fBTcl_ConcatObj\fR eliminates leading and trailing white space
497 as it copies the string representations of the \fIobjv\fR array to the
498 result. If an element of the \fIobjv\fR array consists of nothing but
499 white space, then that object is ignored entirely. This white-space
500 removal was added to make the output of the \fBconcat\fR command
501 cleaner-looking. \fBTcl_ConcatObj\fR returns a pointer to a
502 newly-created object whose ref count is zero.
503
504 .SH "SEE ALSO"
505 Tcl_NewObj, Tcl_IncrRefCount, Tcl_DecrRefCount
506
507 .SH KEYWORDS
508 append, internal representation, object, object type, string object,
509 string type, string representation, concat, concatenate, unicode