Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / html / python / api / unicodeMethodsAndSlots.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="api.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="api.html" title='Python/C API Reference Manual' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="prev" href="builtinCodecs.html" />
13<link rel="parent" href="unicodeObjects.html" />
14<link rel="next" href="bufferObjects.html" />
15<meta name='aesop' content='information' />
16<title>7.3.2.2 Methods and Slot Functions </title>
17</head>
18<body>
19<DIV CLASS="navigation">
20<div id='top-navigation-panel' xml:id='top-navigation-panel'>
21<table align="center" width="100%" cellpadding="0" cellspacing="2">
22<tr>
23<td class='online-navigation'><a rel="prev" title="7.3.2.1 Built-in Codecs"
24 href="builtinCodecs.html"><img src='../icons/previous.png'
25 border='0' height='32' alt='Previous Page' width='32' /></A></td>
26<td class='online-navigation'><a rel="parent" title="7.3.2 Unicode Objects"
27 href="unicodeObjects.html"><img src='../icons/up.png'
28 border='0' height='32' alt='Up One Level' width='32' /></A></td>
29<td class='online-navigation'><a rel="next" title="7.3.3 Buffer Objects"
30 href="bufferObjects.html"><img src='../icons/next.png'
31 border='0' height='32' alt='Next Page' width='32' /></A></td>
32<td align="center" width="100%">Python/C API Reference Manual</td>
33<td class='online-navigation'><a rel="contents" title="Table of Contents"
34 href="contents.html"><img src='../icons/contents.png'
35 border='0' height='32' alt='Contents' width='32' /></A></td>
36<td class='online-navigation'><img src='../icons/blank.png'
37 border='0' height='32' alt='' width='32' /></td>
38<td class='online-navigation'><a rel="index" title="Index"
39 href="genindex.html"><img src='../icons/index.png'
40 border='0' height='32' alt='Index' width='32' /></A></td>
41</tr></table>
42<div class='online-navigation'>
43<b class="navlabel">Previous:</b>
44<a class="sectref" rel="prev" href="builtinCodecs.html">7.3.2.1 Built-in Codecs</A>
45<b class="navlabel">Up:</b>
46<a class="sectref" rel="parent" href="unicodeObjects.html">7.3.2 Unicode Objects</A>
47<b class="navlabel">Next:</b>
48<a class="sectref" rel="next" href="bufferObjects.html">7.3.3 Buffer Objects</A>
49</div>
50<hr /></div>
51</DIV>
52<!--End of Navigation Panel-->
53
54<H3><A NAME="SECTION009322000000000000000"></A><A NAME="unicodeMethodsAndSlots"></A>
55<BR>
567.3.2.2 Methods and Slot Functions
57</H3>
58
59<P>
60The following APIs are capable of handling Unicode objects and strings
61on input (we refer to them as strings in the descriptions) and return
62Unicode objects or integers as appropriate.
63
64<P>
65They all return <tt class="constant">NULL</tt> or <code>-1</code> if an exception occurs.
66
67<P>
68<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>PyObject*&nbsp;<b><tt id='l2h-536' xml:id='l2h-536' class="cfunction">PyUnicode_Concat</tt></b>(</nobr></td><td>PyObject *<var>left</var>,
69 PyObject *<var>right</var>)</td></tr></table></dt>
70<dd>
71<div class="refcount-info">
72 <span class="label">Return value:</span>
73 <span class="value">New reference.</span>
74</div>
75 Concat two strings giving a new Unicode string.
76</dd></dl>
77
78<P>
79<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>PyObject*&nbsp;<b><tt id='l2h-537' xml:id='l2h-537' class="cfunction">PyUnicode_Split</tt></b>(</nobr></td><td>PyObject *<var>s</var>,
80 PyObject *<var>sep</var>,
81 int <var>maxsplit</var>)</td></tr></table></dt>
82<dd>
83<div class="refcount-info">
84 <span class="label">Return value:</span>
85 <span class="value">New reference.</span>
86</div>
87 Split a string giving a list of Unicode strings. If sep is <tt class="constant">NULL</tt>,
88 splitting will be done at all whitespace substrings. Otherwise,
89 splits occur at the given separator. At most <var>maxsplit</var> splits
90 will be done. If negative, no limit is set. Separators are not
91 included in the resulting list.
92</dd></dl>
93
94<P>
95<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>PyObject*&nbsp;<b><tt id='l2h-538' xml:id='l2h-538' class="cfunction">PyUnicode_Splitlines</tt></b>(</nobr></td><td>PyObject *<var>s</var>,
96 int <var>keepend</var>)</td></tr></table></dt>
97<dd>
98<div class="refcount-info">
99 <span class="label">Return value:</span>
100 <span class="value">New reference.</span>
101</div>
102 Split a Unicode string at line breaks, returning a list of Unicode
103 strings. CRLF is considered to be one line break. If <var>keepend</var>
104 is 0, the Line break characters are not included in the resulting
105 strings.
106</dd></dl>
107
108<P>
109<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>PyObject*&nbsp;<b><tt id='l2h-539' xml:id='l2h-539' class="cfunction">PyUnicode_Translate</tt></b>(</nobr></td><td>PyObject *<var>str</var>,
110 PyObject *<var>table</var>,
111 const char *<var>errors</var>)</td></tr></table></dt>
112<dd>
113<div class="refcount-info">
114 <span class="label">Return value:</span>
115 <span class="value">New reference.</span>
116</div>
117 Translate a string by applying a character mapping table to it and
118 return the resulting Unicode object.
119
120<P>
121The mapping table must map Unicode ordinal integers to Unicode
122 ordinal integers or None (causing deletion of the character).
123
124<P>
125Mapping tables need only provide the <tt class="method">__getitem__()</tt>
126 interface; dictionaries and sequences work well. Unmapped character
127 ordinals (ones which cause a <tt class="exception">LookupError</tt>) are left
128 untouched and are copied as-is.
129
130<P>
131<var>errors</var> has the usual meaning for codecs. It may be <tt class="constant">NULL</tt>
132 which indicates to use the default error handling.
133</dd></dl>
134
135<P>
136<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>PyObject*&nbsp;<b><tt id='l2h-540' xml:id='l2h-540' class="cfunction">PyUnicode_Join</tt></b>(</nobr></td><td>PyObject *<var>separator</var>,
137 PyObject *<var>seq</var>)</td></tr></table></dt>
138<dd>
139<div class="refcount-info">
140 <span class="label">Return value:</span>
141 <span class="value">New reference.</span>
142</div>
143 Join a sequence of strings using the given separator and return the
144 resulting Unicode string.
145</dd></dl>
146
147<P>
148<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>int&nbsp;<b><tt id='l2h-541' xml:id='l2h-541' class="cfunction">PyUnicode_Tailmatch</tt></b>(</nobr></td><td>PyObject *<var>str</var>,
149 PyObject *<var>substr</var>,
150 int <var>start</var>,
151 int <var>end</var>,
152 int <var>direction</var>)</td></tr></table></dt>
153<dd>
154<div class="refcount-info">
155 <span class="label">Return value:</span>
156 <span class="value">New reference.</span>
157</div>
158 Return 1 if <var>substr</var> matches <var>str</var>[<var>start</var>:<var>end</var>] at
159 the given tail end (<var>direction</var> == -1 means to do a prefix
160 match, <var>direction</var> == 1 a suffix match), 0 otherwise.
161 Return <code>-1</code> if an error occurred.
162</dd></dl>
163
164<P>
165<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>int&nbsp;<b><tt id='l2h-542' xml:id='l2h-542' class="cfunction">PyUnicode_Find</tt></b>(</nobr></td><td>PyObject *<var>str</var>,
166 PyObject *<var>substr</var>,
167 int <var>start</var>,
168 int <var>end</var>,
169 int <var>direction</var>)</td></tr></table></dt>
170<dd>
171 Return the first position of <var>substr</var> in
172 <var>str</var>[<var>start</var>:<var>end</var>] using the given <var>direction</var>
173 (<var>direction</var> == 1 means to do a forward search,
174 <var>direction</var> == -1 a backward search). The return value is the
175 index of the first match; a value of <code>-1</code> indicates that no
176 match was found, and <code>-2</code> indicates that an error occurred and
177 an exception has been set.
178</dd></dl>
179
180<P>
181<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>int&nbsp;<b><tt id='l2h-543' xml:id='l2h-543' class="cfunction">PyUnicode_Count</tt></b>(</nobr></td><td>PyObject *<var>str</var>,
182 PyObject *<var>substr</var>,
183 int <var>start</var>,
184 int <var>end</var>)</td></tr></table></dt>
185<dd>
186 Return the number of non-overlapping occurrences of <var>substr</var> in
187 <code><var>str</var>[<var>start</var>:<var>end</var>]</code>. Return <code>-1</code> if an
188 error occurred.
189</dd></dl>
190
191<P>
192<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>PyObject*&nbsp;<b><tt id='l2h-544' xml:id='l2h-544' class="cfunction">PyUnicode_Replace</tt></b>(</nobr></td><td>PyObject *<var>str</var>,
193 PyObject *<var>substr</var>,
194 PyObject *<var>replstr</var>,
195 int <var>maxcount</var>)</td></tr></table></dt>
196<dd>
197<div class="refcount-info">
198 <span class="label">Return value:</span>
199 <span class="value">New reference.</span>
200</div>
201 Replace at most <var>maxcount</var> occurrences of <var>substr</var> in
202 <var>str</var> with <var>replstr</var> and return the resulting Unicode object.
203 <var>maxcount</var> == -1 means replace all occurrences.
204</dd></dl>
205
206<P>
207<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>int&nbsp;<b><tt id='l2h-545' xml:id='l2h-545' class="cfunction">PyUnicode_Compare</tt></b>(</nobr></td><td>PyObject *<var>left</var>, PyObject *<var>right</var>)</td></tr></table></dt>
208<dd>
209 Compare two strings and return -1, 0, 1 for less than, equal, and
210 greater than, respectively.
211</dd></dl>
212
213<P>
214<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>PyObject*&nbsp;<b><tt id='l2h-546' xml:id='l2h-546' class="cfunction">PyUnicode_Format</tt></b>(</nobr></td><td>PyObject *<var>format</var>,
215 PyObject *<var>args</var>)</td></tr></table></dt>
216<dd>
217<div class="refcount-info">
218 <span class="label">Return value:</span>
219 <span class="value">New reference.</span>
220</div>
221 Return a new string object from <var>format</var> and <var>args</var>; this
222 is analogous to <code><var>format</var> % <var>args</var></code>. The
223 <var>args</var> argument must be a tuple.
224</dd></dl>
225
226<P>
227<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>int&nbsp;<b><tt id='l2h-547' xml:id='l2h-547' class="cfunction">PyUnicode_Contains</tt></b>(</nobr></td><td>PyObject *<var>container</var>,
228 PyObject *<var>element</var>)</td></tr></table></dt>
229<dd>
230 Check whether <var>element</var> is contained in <var>container</var> and
231 return true or false accordingly.
232
233<P>
234<var>element</var> has to coerce to a one element Unicode
235 string. <code>-1</code> is returned if there was an error.
236</dd></dl>
237
238<P>
239
240<DIV CLASS="navigation">
241<div class='online-navigation'>
242<p></p><hr />
243<table align="center" width="100%" cellpadding="0" cellspacing="2">
244<tr>
245<td class='online-navigation'><a rel="prev" title="7.3.2.1 Built-in Codecs"
246 href="builtinCodecs.html"><img src='../icons/previous.png'
247 border='0' height='32' alt='Previous Page' width='32' /></A></td>
248<td class='online-navigation'><a rel="parent" title="7.3.2 Unicode Objects"
249 href="unicodeObjects.html"><img src='../icons/up.png'
250 border='0' height='32' alt='Up One Level' width='32' /></A></td>
251<td class='online-navigation'><a rel="next" title="7.3.3 Buffer Objects"
252 href="bufferObjects.html"><img src='../icons/next.png'
253 border='0' height='32' alt='Next Page' width='32' /></A></td>
254<td align="center" width="100%">Python/C API Reference Manual</td>
255<td class='online-navigation'><a rel="contents" title="Table of Contents"
256 href="contents.html"><img src='../icons/contents.png'
257 border='0' height='32' alt='Contents' width='32' /></A></td>
258<td class='online-navigation'><img src='../icons/blank.png'
259 border='0' height='32' alt='' width='32' /></td>
260<td class='online-navigation'><a rel="index" title="Index"
261 href="genindex.html"><img src='../icons/index.png'
262 border='0' height='32' alt='Index' width='32' /></A></td>
263</tr></table>
264<div class='online-navigation'>
265<b class="navlabel">Previous:</b>
266<a class="sectref" rel="prev" href="builtinCodecs.html">7.3.2.1 Built-in Codecs</A>
267<b class="navlabel">Up:</b>
268<a class="sectref" rel="parent" href="unicodeObjects.html">7.3.2 Unicode Objects</A>
269<b class="navlabel">Next:</b>
270<a class="sectref" rel="next" href="bufferObjects.html">7.3.3 Buffer Objects</A>
271</div>
272</div>
273<hr />
274<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
275</DIV>
276<!--End of Navigation Panel-->
277<ADDRESS>
278See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
279</ADDRESS>
280</BODY>
281</HTML>