Mercurial > cpython-lru_cache-weakref
annotate Include/unicodeobject.h @ 39940:dfd809dcf680 2.5
Bug #1446043: correctly raise a LookupError if an encoding name given
to encodings.search_function() contains a dot.
(backport from rev. 52075)
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Sat, 30 Sep 2006 11:22:35 +0000 |
| parents | 635b09b1f542 |
| children | d01bd37bf5ce |
| rev | line source |
|---|---|
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 #ifndef Py_UNICODEOBJECT_H |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
2 #define Py_UNICODEOBJECT_H |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
3 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 /* |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 Unicode implementation based on original code by Fredrik Lundh, |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
7 modified by Marc-Andre Lemburg (mal@lemburg.com) according to the |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
8 Unicode Integration Proposal (see file Misc/unicode.txt). |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 |
|
13828
254f8b7c4a83
Changing the CNRI copyright notice according to CNRI's instructions.
Guido van Rossum <guido@python.org>
parents:
13661
diff
changeset
|
10 Copyright (c) Corporation for National Research Initiatives. |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
13 Original header: |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 -------------------------------------------------------------------- |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 * Yet another Unicode string type for Python. This type supports the |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 * 16-bit Basic Multilingual Plane (BMP) only. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 * |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 * Written by Fredrik Lundh, January 1999. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 * |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
21 * Copyright (c) 1999 by Secret Labs AB. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
22 * Copyright (c) 1999 by Fredrik Lundh. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
23 * |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
24 * fredrik@pythonware.com |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
25 * http://www.pythonware.com |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
26 * |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
27 * -------------------------------------------------------------------- |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
28 * This Unicode String Type is |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
29 * |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 * Copyright (c) 1999 by Secret Labs AB |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
31 * Copyright (c) 1999 by Fredrik Lundh |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
32 * |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
33 * By obtaining, using, and/or copying this software and/or its |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
34 * associated documentation, you agree that you have read, understood, |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
35 * and will comply with the following terms and conditions: |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
36 * |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
37 * Permission to use, copy, modify, and distribute this software and its |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
38 * associated documentation for any purpose and without fee is hereby |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
39 * granted, provided that the above copyright notice appears in all |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
40 * copies, and that both that copyright notice and this permission notice |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
41 * appear in supporting documentation, and that the name of Secret Labs |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
42 * AB or the author not be used in advertising or publicity pertaining to |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
43 * distribution of the software without specific, written prior |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
44 * permission. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
45 * |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
46 * SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
47 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
48 * FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR BE LIABLE FOR |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
49 * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
50 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
51 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
52 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
53 * -------------------------------------------------------------------- */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
54 |
| 19980 | 55 #include <ctype.h> |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
56 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
57 /* === Internal API ======================================================= */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
58 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
59 /* --- Internal Unicode Format -------------------------------------------- */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
60 |
|
19343
7257e87e0720
Patch #445762: Support --disable-unicode
Martin v. Löwis <martin@v.loewis.de>
parents:
19121
diff
changeset
|
61 #ifndef Py_USING_UNICODE |
|
7257e87e0720
Patch #445762: Support --disable-unicode
Martin v. Löwis <martin@v.loewis.de>
parents:
19121
diff
changeset
|
62 |
|
7257e87e0720
Patch #445762: Support --disable-unicode
Martin v. Löwis <martin@v.loewis.de>
parents:
19121
diff
changeset
|
63 #define PyUnicode_Check(op) 0 |
|
19849
bf0202dac441
Possibly the end of SF [#460020] bug or feature: unicode() and subclasses.
Tim Peters <tim.peters@gmail.com>
parents:
19589
diff
changeset
|
64 #define PyUnicode_CheckExact(op) 0 |
|
19343
7257e87e0720
Patch #445762: Support --disable-unicode
Martin v. Löwis <martin@v.loewis.de>
parents:
19121
diff
changeset
|
65 |
|
7257e87e0720
Patch #445762: Support --disable-unicode
Martin v. Löwis <martin@v.loewis.de>
parents:
19121
diff
changeset
|
66 #else |
|
7257e87e0720
Patch #445762: Support --disable-unicode
Martin v. Löwis <martin@v.loewis.de>
parents:
19121
diff
changeset
|
67 |
|
18296
22f85c6a6520
Make Unicode work a bit better on Windows...
Fredrik Lundh <fredrik@pythonware.com>
parents:
18292
diff
changeset
|
68 /* FIXME: MvL's new implementation assumes that Py_UNICODE_SIZE is |
|
22f85c6a6520
Make Unicode work a bit better on Windows...
Fredrik Lundh <fredrik@pythonware.com>
parents:
18292
diff
changeset
|
69 properly set, but the default rules below doesn't set it. I'll |
|
22f85c6a6520
Make Unicode work a bit better on Windows...
Fredrik Lundh <fredrik@pythonware.com>
parents:
18292
diff
changeset
|
70 sort this out some other day -- fredrik@pythonware.com */ |
|
22f85c6a6520
Make Unicode work a bit better on Windows...
Fredrik Lundh <fredrik@pythonware.com>
parents:
18292
diff
changeset
|
71 |
|
22f85c6a6520
Make Unicode work a bit better on Windows...
Fredrik Lundh <fredrik@pythonware.com>
parents:
18292
diff
changeset
|
72 #ifndef Py_UNICODE_SIZE |
|
22f85c6a6520
Make Unicode work a bit better on Windows...
Fredrik Lundh <fredrik@pythonware.com>
parents:
18292
diff
changeset
|
73 #error Must define Py_UNICODE_SIZE |
|
22f85c6a6520
Make Unicode work a bit better on Windows...
Fredrik Lundh <fredrik@pythonware.com>
parents:
18292
diff
changeset
|
74 #endif |
|
22f85c6a6520
Make Unicode work a bit better on Windows...
Fredrik Lundh <fredrik@pythonware.com>
parents:
18292
diff
changeset
|
75 |
|
18324
3ba7a358ce02
use Py_UNICODE_WIDE instead of USE_UCS4_STORAGE and Py_UNICODE_SIZE
Fredrik Lundh <fredrik@pythonware.com>
parents:
18298
diff
changeset
|
76 /* Setting Py_UNICODE_WIDE enables UCS-4 storage. Otherwise, Unicode |
|
3ba7a358ce02
use Py_UNICODE_WIDE instead of USE_UCS4_STORAGE and Py_UNICODE_SIZE
Fredrik Lundh <fredrik@pythonware.com>
parents:
18298
diff
changeset
|
77 strings are stored as UCS-2 (with limited support for UTF-16) */ |
|
3ba7a358ce02
use Py_UNICODE_WIDE instead of USE_UCS4_STORAGE and Py_UNICODE_SIZE
Fredrik Lundh <fredrik@pythonware.com>
parents:
18298
diff
changeset
|
78 |
|
3ba7a358ce02
use Py_UNICODE_WIDE instead of USE_UCS4_STORAGE and Py_UNICODE_SIZE
Fredrik Lundh <fredrik@pythonware.com>
parents:
18298
diff
changeset
|
79 #if Py_UNICODE_SIZE >= 4 |
|
3ba7a358ce02
use Py_UNICODE_WIDE instead of USE_UCS4_STORAGE and Py_UNICODE_SIZE
Fredrik Lundh <fredrik@pythonware.com>
parents:
18298
diff
changeset
|
80 #define Py_UNICODE_WIDE |
|
18292
ffbb9c918ac0
Support using UCS-4 as the Py_UNICODE type:
Martin v. Löwis <martin@v.loewis.de>
parents:
18280
diff
changeset
|
81 #endif |
|
18280
0632dcd69ea3
experimental UCS-4 support: added USE_UCS4_STORAGE define to
Fredrik Lundh <fredrik@pythonware.com>
parents:
17887
diff
changeset
|
82 |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
83 /* Set these flags if the platform has "wchar.h", "wctype.h" and the |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
84 wchar_t type is a 16-bit unsigned type */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
85 /* #define HAVE_WCHAR_H */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
86 /* #define HAVE_USABLE_WCHAR_T */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
87 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
88 /* Defaults for various platforms */ |
|
18292
ffbb9c918ac0
Support using UCS-4 as the Py_UNICODE type:
Martin v. Löwis <martin@v.loewis.de>
parents:
18280
diff
changeset
|
89 #ifndef PY_UNICODE_TYPE |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
90 |
|
18280
0632dcd69ea3
experimental UCS-4 support: added USE_UCS4_STORAGE define to
Fredrik Lundh <fredrik@pythonware.com>
parents:
17887
diff
changeset
|
91 /* Windows has a usable wchar_t type (unless we're using UCS-4) */ |
|
18324
3ba7a358ce02
use Py_UNICODE_WIDE instead of USE_UCS4_STORAGE and Py_UNICODE_SIZE
Fredrik Lundh <fredrik@pythonware.com>
parents:
18298
diff
changeset
|
92 # if defined(MS_WIN32) && Py_UNICODE_SIZE == 2 |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
93 # define HAVE_USABLE_WCHAR_T |
|
18292
ffbb9c918ac0
Support using UCS-4 as the Py_UNICODE type:
Martin v. Löwis <martin@v.loewis.de>
parents:
18280
diff
changeset
|
94 # define PY_UNICODE_TYPE wchar_t |
|
ffbb9c918ac0
Support using UCS-4 as the Py_UNICODE type:
Martin v. Löwis <martin@v.loewis.de>
parents:
18280
diff
changeset
|
95 # endif |
|
ffbb9c918ac0
Support using UCS-4 as the Py_UNICODE type:
Martin v. Löwis <martin@v.loewis.de>
parents:
18280
diff
changeset
|
96 |
|
18324
3ba7a358ce02
use Py_UNICODE_WIDE instead of USE_UCS4_STORAGE and Py_UNICODE_SIZE
Fredrik Lundh <fredrik@pythonware.com>
parents:
18298
diff
changeset
|
97 # if defined(Py_UNICODE_WIDE) |
|
18292
ffbb9c918ac0
Support using UCS-4 as the Py_UNICODE type:
Martin v. Löwis <martin@v.loewis.de>
parents:
18280
diff
changeset
|
98 # define PY_UNICODE_TYPE Py_UCS4 |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
99 # endif |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
100 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
101 #endif |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
102 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
103 /* If the compiler provides a wchar_t type we try to support it |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
104 through the interface functions PyUnicode_FromWideChar() and |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
105 PyUnicode_AsWideChar(). */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
106 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
107 #ifdef HAVE_USABLE_WCHAR_T |
|
13917
03fa40528d17
Added #fndef's to avoid compiler errors.
Marc-André Lemburg <mal@egenix.com>
parents:
13837
diff
changeset
|
108 # ifndef HAVE_WCHAR_H |
|
03fa40528d17
Added #fndef's to avoid compiler errors.
Marc-André Lemburg <mal@egenix.com>
parents:
13837
diff
changeset
|
109 # define HAVE_WCHAR_H |
|
03fa40528d17
Added #fndef's to avoid compiler errors.
Marc-André Lemburg <mal@egenix.com>
parents:
13837
diff
changeset
|
110 # endif |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
111 #endif |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
112 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
113 #ifdef HAVE_WCHAR_H |
| 12074 | 114 /* Work around a cosmetic bug in BSDI 4.x wchar.h; thanks to Thomas Wouters */ |
| 115 # ifdef _HAVE_BSDI | |
| 116 # include <time.h> | |
| 117 # endif | |
| 19980 | 118 # include <wchar.h> |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
119 #endif |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
120 |
|
18292
ffbb9c918ac0
Support using UCS-4 as the Py_UNICODE type:
Martin v. Löwis <martin@v.loewis.de>
parents:
18280
diff
changeset
|
121 /* |
|
ffbb9c918ac0
Support using UCS-4 as the Py_UNICODE type:
Martin v. Löwis <martin@v.loewis.de>
parents:
18280
diff
changeset
|
122 * Use this typedef when you need to represent a UTF-16 surrogate pair |
|
ffbb9c918ac0
Support using UCS-4 as the Py_UNICODE type:
Martin v. Löwis <martin@v.loewis.de>
parents:
18280
diff
changeset
|
123 * as single unsigned integer. |
|
ffbb9c918ac0
Support using UCS-4 as the Py_UNICODE type:
Martin v. Löwis <martin@v.loewis.de>
parents:
18280
diff
changeset
|
124 */ |
|
ffbb9c918ac0
Support using UCS-4 as the Py_UNICODE type:
Martin v. Löwis <martin@v.loewis.de>
parents:
18280
diff
changeset
|
125 #if SIZEOF_INT >= 4 |
|
ffbb9c918ac0
Support using UCS-4 as the Py_UNICODE type:
Martin v. Löwis <martin@v.loewis.de>
parents:
18280
diff
changeset
|
126 typedef unsigned int Py_UCS4; |
|
ffbb9c918ac0
Support using UCS-4 as the Py_UNICODE type:
Martin v. Löwis <martin@v.loewis.de>
parents:
18280
diff
changeset
|
127 #elif SIZEOF_LONG >= 4 |
|
ffbb9c918ac0
Support using UCS-4 as the Py_UNICODE type:
Martin v. Löwis <martin@v.loewis.de>
parents:
18280
diff
changeset
|
128 typedef unsigned long Py_UCS4; |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
129 #endif |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
130 |
|
18292
ffbb9c918ac0
Support using UCS-4 as the Py_UNICODE type:
Martin v. Löwis <martin@v.loewis.de>
parents:
18280
diff
changeset
|
131 typedef PY_UNICODE_TYPE Py_UNICODE; |
|
13393
bcb14627b8f4
Bill Tutt: Added Py_UCS4 typedef to hold UCS4 values (these need
Marc-André Lemburg <mal@egenix.com>
parents:
13352
diff
changeset
|
132 |
|
18911
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
133 /* --- UCS-2/UCS-4 Name Mangling ------------------------------------------ */ |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
134 |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
135 /* Unicode API names are mangled to assure that UCS-2 and UCS-4 builds |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
136 produce different external names and thus cause import errors in |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
137 case Python interpreters and extensions with mixed compiled in |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
138 Unicode width assumptions are combined. */ |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
139 |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
140 #ifndef Py_UNICODE_WIDE |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
141 |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
142 # define PyUnicode_AsASCIIString PyUnicodeUCS2_AsASCIIString |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
143 # define PyUnicode_AsCharmapString PyUnicodeUCS2_AsCharmapString |
|
32551
f46d49e2e0f0
Allow string and unicode return types from .encode()/.decode()
Marc-André Lemburg <mal@egenix.com>
parents:
32197
diff
changeset
|
144 # define PyUnicode_AsEncodedObject PyUnicodeUCS2_AsEncodedObject |
|
18911
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
145 # define PyUnicode_AsEncodedString PyUnicodeUCS2_AsEncodedString |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
146 # define PyUnicode_AsLatin1String PyUnicodeUCS2_AsLatin1String |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
147 # define PyUnicode_AsRawUnicodeEscapeString PyUnicodeUCS2_AsRawUnicodeEscapeString |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
148 # define PyUnicode_AsUTF16String PyUnicodeUCS2_AsUTF16String |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
149 # define PyUnicode_AsUTF8String PyUnicodeUCS2_AsUTF8String |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
150 # define PyUnicode_AsUnicode PyUnicodeUCS2_AsUnicode |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
151 # define PyUnicode_AsUnicodeEscapeString PyUnicodeUCS2_AsUnicodeEscapeString |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
152 # define PyUnicode_AsWideChar PyUnicodeUCS2_AsWideChar |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
153 # define PyUnicode_Compare PyUnicodeUCS2_Compare |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
154 # define PyUnicode_Concat PyUnicodeUCS2_Concat |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
155 # define PyUnicode_Contains PyUnicodeUCS2_Contains |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
156 # define PyUnicode_Count PyUnicodeUCS2_Count |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
157 # define PyUnicode_Decode PyUnicodeUCS2_Decode |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
158 # define PyUnicode_DecodeASCII PyUnicodeUCS2_DecodeASCII |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
159 # define PyUnicode_DecodeCharmap PyUnicodeUCS2_DecodeCharmap |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
160 # define PyUnicode_DecodeLatin1 PyUnicodeUCS2_DecodeLatin1 |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
161 # define PyUnicode_DecodeRawUnicodeEscape PyUnicodeUCS2_DecodeRawUnicodeEscape |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
162 # define PyUnicode_DecodeUTF16 PyUnicodeUCS2_DecodeUTF16 |
|
33428
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
163 # define PyUnicode_DecodeUTF16Stateful PyUnicodeUCS2_DecodeUTF16Stateful |
|
18911
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
164 # define PyUnicode_DecodeUTF8 PyUnicodeUCS2_DecodeUTF8 |
|
33428
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
165 # define PyUnicode_DecodeUTF8Stateful PyUnicodeUCS2_DecodeUTF8Stateful |
|
18911
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
166 # define PyUnicode_DecodeUnicodeEscape PyUnicodeUCS2_DecodeUnicodeEscape |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
167 # define PyUnicode_Encode PyUnicodeUCS2_Encode |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
168 # define PyUnicode_EncodeASCII PyUnicodeUCS2_EncodeASCII |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
169 # define PyUnicode_EncodeCharmap PyUnicodeUCS2_EncodeCharmap |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
170 # define PyUnicode_EncodeDecimal PyUnicodeUCS2_EncodeDecimal |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
171 # define PyUnicode_EncodeLatin1 PyUnicodeUCS2_EncodeLatin1 |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
172 # define PyUnicode_EncodeRawUnicodeEscape PyUnicodeUCS2_EncodeRawUnicodeEscape |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
173 # define PyUnicode_EncodeUTF16 PyUnicodeUCS2_EncodeUTF16 |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
174 # define PyUnicode_EncodeUTF8 PyUnicodeUCS2_EncodeUTF8 |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
175 # define PyUnicode_EncodeUnicodeEscape PyUnicodeUCS2_EncodeUnicodeEscape |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
176 # define PyUnicode_Find PyUnicodeUCS2_Find |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
177 # define PyUnicode_Format PyUnicodeUCS2_Format |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
178 # define PyUnicode_FromEncodedObject PyUnicodeUCS2_FromEncodedObject |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
179 # define PyUnicode_FromObject PyUnicodeUCS2_FromObject |
|
24753
27ae978bee58
Add name mangling for new PyUnicode_FromOrdinal() and fix declaration
Marc-André Lemburg <mal@egenix.com>
parents:
24752
diff
changeset
|
180 # define PyUnicode_FromOrdinal PyUnicodeUCS2_FromOrdinal |
|
18911
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
181 # define PyUnicode_FromUnicode PyUnicodeUCS2_FromUnicode |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
182 # define PyUnicode_FromWideChar PyUnicodeUCS2_FromWideChar |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
183 # define PyUnicode_GetDefaultEncoding PyUnicodeUCS2_GetDefaultEncoding |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
184 # define PyUnicode_GetMax PyUnicodeUCS2_GetMax |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
185 # define PyUnicode_GetSize PyUnicodeUCS2_GetSize |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
186 # define PyUnicode_Join PyUnicodeUCS2_Join |
|
38335
f9332ad4287a
needforspeed: partition implementation, part two.
Fredrik Lundh <fredrik@pythonware.com>
parents:
38242
diff
changeset
|
187 # define PyUnicode_Partition PyUnicodeUCS2_Partition |
|
38390
76807902a2f5
needforspeed: added rpartition implementation
Fredrik Lundh <fredrik@pythonware.com>
parents:
38335
diff
changeset
|
188 # define PyUnicode_RPartition PyUnicodeUCS2_RPartition |
|
76807902a2f5
needforspeed: added rpartition implementation
Fredrik Lundh <fredrik@pythonware.com>
parents:
38335
diff
changeset
|
189 # define PyUnicode_RSplit PyUnicodeUCS2_RSplit |
|
18911
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
190 # define PyUnicode_Replace PyUnicodeUCS2_Replace |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
191 # define PyUnicode_Resize PyUnicodeUCS2_Resize |
|
39487
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
192 # define PyUnicode_RichCompare PyUnicodeUCS2_RichCompare |
|
18911
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
193 # define PyUnicode_SetDefaultEncoding PyUnicodeUCS2_SetDefaultEncoding |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
194 # define PyUnicode_Split PyUnicodeUCS2_Split |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
195 # define PyUnicode_Splitlines PyUnicodeUCS2_Splitlines |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
196 # define PyUnicode_Tailmatch PyUnicodeUCS2_Tailmatch |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
197 # define PyUnicode_Translate PyUnicodeUCS2_Translate |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
198 # define PyUnicode_TranslateCharmap PyUnicodeUCS2_TranslateCharmap |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
199 # define _PyUnicode_AsDefaultEncodedString _PyUnicodeUCS2_AsDefaultEncodedString |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
200 # define _PyUnicode_Fini _PyUnicodeUCS2_Fini |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
201 # define _PyUnicode_Init _PyUnicodeUCS2_Init |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
202 # define _PyUnicode_IsAlpha _PyUnicodeUCS2_IsAlpha |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
203 # define _PyUnicode_IsDecimalDigit _PyUnicodeUCS2_IsDecimalDigit |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
204 # define _PyUnicode_IsDigit _PyUnicodeUCS2_IsDigit |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
205 # define _PyUnicode_IsLinebreak _PyUnicodeUCS2_IsLinebreak |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
206 # define _PyUnicode_IsLowercase _PyUnicodeUCS2_IsLowercase |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
207 # define _PyUnicode_IsNumeric _PyUnicodeUCS2_IsNumeric |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
208 # define _PyUnicode_IsTitlecase _PyUnicodeUCS2_IsTitlecase |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
209 # define _PyUnicode_IsUppercase _PyUnicodeUCS2_IsUppercase |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
210 # define _PyUnicode_IsWhitespace _PyUnicodeUCS2_IsWhitespace |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
211 # define _PyUnicode_ToDecimalDigit _PyUnicodeUCS2_ToDecimalDigit |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
212 # define _PyUnicode_ToDigit _PyUnicodeUCS2_ToDigit |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
213 # define _PyUnicode_ToLowercase _PyUnicodeUCS2_ToLowercase |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
214 # define _PyUnicode_ToNumeric _PyUnicodeUCS2_ToNumeric |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
215 # define _PyUnicode_ToTitlecase _PyUnicodeUCS2_ToTitlecase |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
216 # define _PyUnicode_ToUppercase _PyUnicodeUCS2_ToUppercase |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
217 |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
218 #else |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
219 |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
220 # define PyUnicode_AsASCIIString PyUnicodeUCS4_AsASCIIString |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
221 # define PyUnicode_AsCharmapString PyUnicodeUCS4_AsCharmapString |
|
32551
f46d49e2e0f0
Allow string and unicode return types from .encode()/.decode()
Marc-André Lemburg <mal@egenix.com>
parents:
32197
diff
changeset
|
222 # define PyUnicode_AsEncodedObject PyUnicodeUCS4_AsEncodedObject |
|
18911
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
223 # define PyUnicode_AsEncodedString PyUnicodeUCS4_AsEncodedString |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
224 # define PyUnicode_AsLatin1String PyUnicodeUCS4_AsLatin1String |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
225 # define PyUnicode_AsRawUnicodeEscapeString PyUnicodeUCS4_AsRawUnicodeEscapeString |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
226 # define PyUnicode_AsUTF16String PyUnicodeUCS4_AsUTF16String |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
227 # define PyUnicode_AsUTF8String PyUnicodeUCS4_AsUTF8String |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
228 # define PyUnicode_AsUnicode PyUnicodeUCS4_AsUnicode |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
229 # define PyUnicode_AsUnicodeEscapeString PyUnicodeUCS4_AsUnicodeEscapeString |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
230 # define PyUnicode_AsWideChar PyUnicodeUCS4_AsWideChar |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
231 # define PyUnicode_Compare PyUnicodeUCS4_Compare |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
232 # define PyUnicode_Concat PyUnicodeUCS4_Concat |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
233 # define PyUnicode_Contains PyUnicodeUCS4_Contains |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
234 # define PyUnicode_Count PyUnicodeUCS4_Count |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
235 # define PyUnicode_Decode PyUnicodeUCS4_Decode |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
236 # define PyUnicode_DecodeASCII PyUnicodeUCS4_DecodeASCII |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
237 # define PyUnicode_DecodeCharmap PyUnicodeUCS4_DecodeCharmap |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
238 # define PyUnicode_DecodeLatin1 PyUnicodeUCS4_DecodeLatin1 |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
239 # define PyUnicode_DecodeRawUnicodeEscape PyUnicodeUCS4_DecodeRawUnicodeEscape |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
240 # define PyUnicode_DecodeUTF16 PyUnicodeUCS4_DecodeUTF16 |
|
33428
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
241 # define PyUnicode_DecodeUTF16Stateful PyUnicodeUCS4_DecodeUTF16Stateful |
|
18911
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
242 # define PyUnicode_DecodeUTF8 PyUnicodeUCS4_DecodeUTF8 |
|
33428
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
243 # define PyUnicode_DecodeUTF8Stateful PyUnicodeUCS4_DecodeUTF8Stateful |
|
18911
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
244 # define PyUnicode_DecodeUnicodeEscape PyUnicodeUCS4_DecodeUnicodeEscape |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
245 # define PyUnicode_Encode PyUnicodeUCS4_Encode |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
246 # define PyUnicode_EncodeASCII PyUnicodeUCS4_EncodeASCII |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
247 # define PyUnicode_EncodeCharmap PyUnicodeUCS4_EncodeCharmap |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
248 # define PyUnicode_EncodeDecimal PyUnicodeUCS4_EncodeDecimal |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
249 # define PyUnicode_EncodeLatin1 PyUnicodeUCS4_EncodeLatin1 |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
250 # define PyUnicode_EncodeRawUnicodeEscape PyUnicodeUCS4_EncodeRawUnicodeEscape |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
251 # define PyUnicode_EncodeUTF16 PyUnicodeUCS4_EncodeUTF16 |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
252 # define PyUnicode_EncodeUTF8 PyUnicodeUCS4_EncodeUTF8 |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
253 # define PyUnicode_EncodeUnicodeEscape PyUnicodeUCS4_EncodeUnicodeEscape |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
254 # define PyUnicode_Find PyUnicodeUCS4_Find |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
255 # define PyUnicode_Format PyUnicodeUCS4_Format |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
256 # define PyUnicode_FromEncodedObject PyUnicodeUCS4_FromEncodedObject |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
257 # define PyUnicode_FromObject PyUnicodeUCS4_FromObject |
|
24753
27ae978bee58
Add name mangling for new PyUnicode_FromOrdinal() and fix declaration
Marc-André Lemburg <mal@egenix.com>
parents:
24752
diff
changeset
|
258 # define PyUnicode_FromOrdinal PyUnicodeUCS4_FromOrdinal |
|
18911
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
259 # define PyUnicode_FromUnicode PyUnicodeUCS4_FromUnicode |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
260 # define PyUnicode_FromWideChar PyUnicodeUCS4_FromWideChar |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
261 # define PyUnicode_GetDefaultEncoding PyUnicodeUCS4_GetDefaultEncoding |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
262 # define PyUnicode_GetMax PyUnicodeUCS4_GetMax |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
263 # define PyUnicode_GetSize PyUnicodeUCS4_GetSize |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
264 # define PyUnicode_Join PyUnicodeUCS4_Join |
|
38335
f9332ad4287a
needforspeed: partition implementation, part two.
Fredrik Lundh <fredrik@pythonware.com>
parents:
38242
diff
changeset
|
265 # define PyUnicode_Partition PyUnicodeUCS4_Partition |
|
38390
76807902a2f5
needforspeed: added rpartition implementation
Fredrik Lundh <fredrik@pythonware.com>
parents:
38335
diff
changeset
|
266 # define PyUnicode_RPartition PyUnicodeUCS4_RPartition |
|
76807902a2f5
needforspeed: added rpartition implementation
Fredrik Lundh <fredrik@pythonware.com>
parents:
38335
diff
changeset
|
267 # define PyUnicode_RSplit PyUnicodeUCS4_RSplit |
|
18911
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
268 # define PyUnicode_Replace PyUnicodeUCS4_Replace |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
269 # define PyUnicode_Resize PyUnicodeUCS4_Resize |
|
39487
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
270 # define PyUnicode_RichCompare PyUnicodeUCS4_RichCompare |
|
18911
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
271 # define PyUnicode_SetDefaultEncoding PyUnicodeUCS4_SetDefaultEncoding |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
272 # define PyUnicode_Split PyUnicodeUCS4_Split |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
273 # define PyUnicode_Splitlines PyUnicodeUCS4_Splitlines |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
274 # define PyUnicode_Tailmatch PyUnicodeUCS4_Tailmatch |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
275 # define PyUnicode_Translate PyUnicodeUCS4_Translate |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
276 # define PyUnicode_TranslateCharmap PyUnicodeUCS4_TranslateCharmap |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
277 # define _PyUnicode_AsDefaultEncodedString _PyUnicodeUCS4_AsDefaultEncodedString |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
278 # define _PyUnicode_Fini _PyUnicodeUCS4_Fini |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
279 # define _PyUnicode_Init _PyUnicodeUCS4_Init |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
280 # define _PyUnicode_IsAlpha _PyUnicodeUCS4_IsAlpha |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
281 # define _PyUnicode_IsDecimalDigit _PyUnicodeUCS4_IsDecimalDigit |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
282 # define _PyUnicode_IsDigit _PyUnicodeUCS4_IsDigit |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
283 # define _PyUnicode_IsLinebreak _PyUnicodeUCS4_IsLinebreak |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
284 # define _PyUnicode_IsLowercase _PyUnicodeUCS4_IsLowercase |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
285 # define _PyUnicode_IsNumeric _PyUnicodeUCS4_IsNumeric |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
286 # define _PyUnicode_IsTitlecase _PyUnicodeUCS4_IsTitlecase |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
287 # define _PyUnicode_IsUppercase _PyUnicodeUCS4_IsUppercase |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
288 # define _PyUnicode_IsWhitespace _PyUnicodeUCS4_IsWhitespace |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
289 # define _PyUnicode_ToDecimalDigit _PyUnicodeUCS4_ToDecimalDigit |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
290 # define _PyUnicode_ToDigit _PyUnicodeUCS4_ToDigit |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
291 # define _PyUnicode_ToLowercase _PyUnicodeUCS4_ToLowercase |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
292 # define _PyUnicode_ToNumeric _PyUnicodeUCS4_ToNumeric |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
293 # define _PyUnicode_ToTitlecase _PyUnicodeUCS4_ToTitlecase |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
294 # define _PyUnicode_ToUppercase _PyUnicodeUCS4_ToUppercase |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
295 |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
296 |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
297 #endif |
|
55b45b47fc48
As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents:
18887
diff
changeset
|
298 |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
299 /* --- Internal Unicode Operations ---------------------------------------- */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
300 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
301 /* If you want Python to use the compiler's wctype.h functions instead |
|
12025
7994d9db7f4d
On 17-Mar-2000, Marc-Andre Lemburg said:
Barry Warsaw <barry@python.org>
parents:
12002
diff
changeset
|
302 of the ones supplied with Python, define WANT_WCTYPE_FUNCTIONS or |
|
33864
6b61af083493
SF patch #1056231: typo in comment (unicodeobject.h)
Raymond Hettinger <python@rcn.com>
parents:
33428
diff
changeset
|
303 configure Python using --with-wctype-functions. This reduces the |
|
12025
7994d9db7f4d
On 17-Mar-2000, Marc-Andre Lemburg said:
Barry Warsaw <barry@python.org>
parents:
12002
diff
changeset
|
304 interpreter's code size. */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
305 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
306 #if defined(HAVE_USABLE_WCHAR_T) && defined(WANT_WCTYPE_FUNCTIONS) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
307 |
| 19980 | 308 #include <wctype.h> |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
309 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
310 #define Py_UNICODE_ISSPACE(ch) iswspace(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
311 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
312 #define Py_UNICODE_ISLOWER(ch) iswlower(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
313 #define Py_UNICODE_ISUPPER(ch) iswupper(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
314 #define Py_UNICODE_ISTITLE(ch) _PyUnicode_IsTitlecase(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
315 #define Py_UNICODE_ISLINEBREAK(ch) _PyUnicode_IsLinebreak(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
316 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
317 #define Py_UNICODE_TOLOWER(ch) towlower(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
318 #define Py_UNICODE_TOUPPER(ch) towupper(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
319 #define Py_UNICODE_TOTITLE(ch) _PyUnicode_ToTitlecase(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
320 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
321 #define Py_UNICODE_ISDECIMAL(ch) _PyUnicode_IsDecimalDigit(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
322 #define Py_UNICODE_ISDIGIT(ch) _PyUnicode_IsDigit(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
323 #define Py_UNICODE_ISNUMERIC(ch) _PyUnicode_IsNumeric(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
324 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
325 #define Py_UNICODE_TODECIMAL(ch) _PyUnicode_ToDecimalDigit(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
326 #define Py_UNICODE_TODIGIT(ch) _PyUnicode_ToDigit(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
327 #define Py_UNICODE_TONUMERIC(ch) _PyUnicode_ToNumeric(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
328 |
|
13352
d88535ccaee5
Modified the ISALPHA and ISALNUM macros to use the new lookup APIs
Marc-André Lemburg <mal@egenix.com>
parents:
13320
diff
changeset
|
329 #define Py_UNICODE_ISALPHA(ch) iswalpha(ch) |
|
d88535ccaee5
Modified the ISALPHA and ISALNUM macros to use the new lookup APIs
Marc-André Lemburg <mal@egenix.com>
parents:
13320
diff
changeset
|
330 |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
331 #else |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
332 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
333 #define Py_UNICODE_ISSPACE(ch) _PyUnicode_IsWhitespace(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
334 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
335 #define Py_UNICODE_ISLOWER(ch) _PyUnicode_IsLowercase(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
336 #define Py_UNICODE_ISUPPER(ch) _PyUnicode_IsUppercase(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
337 #define Py_UNICODE_ISTITLE(ch) _PyUnicode_IsTitlecase(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
338 #define Py_UNICODE_ISLINEBREAK(ch) _PyUnicode_IsLinebreak(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
339 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
340 #define Py_UNICODE_TOLOWER(ch) _PyUnicode_ToLowercase(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
341 #define Py_UNICODE_TOUPPER(ch) _PyUnicode_ToUppercase(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
342 #define Py_UNICODE_TOTITLE(ch) _PyUnicode_ToTitlecase(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
343 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
344 #define Py_UNICODE_ISDECIMAL(ch) _PyUnicode_IsDecimalDigit(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
345 #define Py_UNICODE_ISDIGIT(ch) _PyUnicode_IsDigit(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
346 #define Py_UNICODE_ISNUMERIC(ch) _PyUnicode_IsNumeric(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
347 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
348 #define Py_UNICODE_TODECIMAL(ch) _PyUnicode_ToDecimalDigit(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
349 #define Py_UNICODE_TODIGIT(ch) _PyUnicode_ToDigit(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
350 #define Py_UNICODE_TONUMERIC(ch) _PyUnicode_ToNumeric(ch) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
351 |
|
13352
d88535ccaee5
Modified the ISALPHA and ISALNUM macros to use the new lookup APIs
Marc-André Lemburg <mal@egenix.com>
parents:
13320
diff
changeset
|
352 #define Py_UNICODE_ISALPHA(ch) _PyUnicode_IsAlpha(ch) |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
353 |
|
13352
d88535ccaee5
Modified the ISALPHA and ISALNUM macros to use the new lookup APIs
Marc-André Lemburg <mal@egenix.com>
parents:
13320
diff
changeset
|
354 #endif |
|
13320
67a04816ea50
Added new Py_UNICODE_ISALPHA() and Py_UNICODE_ISALNUM() macros
Marc-André Lemburg <mal@egenix.com>
parents:
12956
diff
changeset
|
355 |
|
67a04816ea50
Added new Py_UNICODE_ISALPHA() and Py_UNICODE_ISALNUM() macros
Marc-André Lemburg <mal@egenix.com>
parents:
12956
diff
changeset
|
356 #define Py_UNICODE_ISALNUM(ch) \ |
|
67a04816ea50
Added new Py_UNICODE_ISALPHA() and Py_UNICODE_ISALNUM() macros
Marc-André Lemburg <mal@egenix.com>
parents:
12956
diff
changeset
|
357 (Py_UNICODE_ISALPHA(ch) || \ |
|
67a04816ea50
Added new Py_UNICODE_ISALPHA() and Py_UNICODE_ISALNUM() macros
Marc-André Lemburg <mal@egenix.com>
parents:
12956
diff
changeset
|
358 Py_UNICODE_ISDECIMAL(ch) || \ |
|
67a04816ea50
Added new Py_UNICODE_ISALPHA() and Py_UNICODE_ISALNUM() macros
Marc-André Lemburg <mal@egenix.com>
parents:
12956
diff
changeset
|
359 Py_UNICODE_ISDIGIT(ch) || \ |
|
67a04816ea50
Added new Py_UNICODE_ISALPHA() and Py_UNICODE_ISALNUM() macros
Marc-André Lemburg <mal@egenix.com>
parents:
12956
diff
changeset
|
360 Py_UNICODE_ISNUMERIC(ch)) |
|
67a04816ea50
Added new Py_UNICODE_ISALPHA() and Py_UNICODE_ISALNUM() macros
Marc-André Lemburg <mal@egenix.com>
parents:
12956
diff
changeset
|
361 |
|
38457
551814e4b471
needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents:
38390
diff
changeset
|
362 #define Py_UNICODE_COPY(target, source, length) \ |
|
551814e4b471
needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents:
38390
diff
changeset
|
363 Py_MEMCPY((target), (source), (length)*sizeof(Py_UNICODE)) |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
364 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
365 #define Py_UNICODE_FILL(target, value, length) do\ |
|
38239
604af867c65f
needforspeed: use memcpy for "long" strings; use a better algorithm
Fredrik Lundh <fredrik@pythonware.com>
parents:
38238
diff
changeset
|
366 {Py_ssize_t i_; Py_UNICODE *t_ = (target); Py_UNICODE v_ = (value);\ |
|
604af867c65f
needforspeed: use memcpy for "long" strings; use a better algorithm
Fredrik Lundh <fredrik@pythonware.com>
parents:
38238
diff
changeset
|
367 for (i_ = 0; i_ < (length); i_++) t_[i_] = v_;\ |
|
38238
feb00df91922
needforspeed: speed up unicode repeat, unicode string copy
Fredrik Lundh <fredrik@pythonware.com>
parents:
36501
diff
changeset
|
368 } while (0) |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
369 |
|
38242
0de9a789de39
needforspeed: check first *and* last character before doing a full memcmp
Fredrik Lundh <fredrik@pythonware.com>
parents:
38239
diff
changeset
|
370 /* check if substring matches at given offset. the offset must be |
|
0de9a789de39
needforspeed: check first *and* last character before doing a full memcmp
Fredrik Lundh <fredrik@pythonware.com>
parents:
38239
diff
changeset
|
371 valid, and the substring must not be empty */ |
|
0de9a789de39
needforspeed: check first *and* last character before doing a full memcmp
Fredrik Lundh <fredrik@pythonware.com>
parents:
38239
diff
changeset
|
372 #define Py_UNICODE_MATCH(string, offset, substring) \ |
|
0de9a789de39
needforspeed: check first *and* last character before doing a full memcmp
Fredrik Lundh <fredrik@pythonware.com>
parents:
38239
diff
changeset
|
373 ((*((string)->str + (offset)) == *((substring)->str)) && \ |
|
0de9a789de39
needforspeed: check first *and* last character before doing a full memcmp
Fredrik Lundh <fredrik@pythonware.com>
parents:
38239
diff
changeset
|
374 ((*((string)->str + (offset) + (substring)->length-1) == *((substring)->str + (substring)->length-1))) && \ |
|
0de9a789de39
needforspeed: check first *and* last character before doing a full memcmp
Fredrik Lundh <fredrik@pythonware.com>
parents:
38239
diff
changeset
|
375 !memcmp((string)->str + (offset), (substring)->str, (substring)->length*sizeof(Py_UNICODE))) |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
376 |
|
12025
7994d9db7f4d
On 17-Mar-2000, Marc-Andre Lemburg said:
Barry Warsaw <barry@python.org>
parents:
12002
diff
changeset
|
377 #ifdef __cplusplus |
|
7994d9db7f4d
On 17-Mar-2000, Marc-Andre Lemburg said:
Barry Warsaw <barry@python.org>
parents:
12002
diff
changeset
|
378 extern "C" { |
|
7994d9db7f4d
On 17-Mar-2000, Marc-Andre Lemburg said:
Barry Warsaw <barry@python.org>
parents:
12002
diff
changeset
|
379 #endif |
|
7994d9db7f4d
On 17-Mar-2000, Marc-Andre Lemburg said:
Barry Warsaw <barry@python.org>
parents:
12002
diff
changeset
|
380 |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
381 /* --- Unicode Type ------------------------------------------------------- */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
382 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
383 typedef struct { |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
384 PyObject_HEAD |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
385 Py_ssize_t length; /* Length of raw Unicode data in buffer */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
386 Py_UNICODE *str; /* Raw Unicode buffer */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
387 long hash; /* Hash value; -1 if not set */ |
|
13837
2badb322355f
This patch finalizes the move from UTF-8 to a default encoding in
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
388 PyObject *defenc; /* (Default) Encoded version as Python |
|
2badb322355f
This patch finalizes the move from UTF-8 to a default encoding in
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
389 string, or NULL; this is used for |
|
2badb322355f
This patch finalizes the move from UTF-8 to a default encoding in
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
390 implementing the buffer protocol */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
391 } PyUnicodeObject; |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
392 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
393 PyAPI_DATA(PyTypeObject) PyUnicode_Type; |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
394 |
|
19589
844553473fa4
Make the Py<type>_Check() macro use PyObject_TypeCheck().
Guido van Rossum <guido@python.org>
parents:
19343
diff
changeset
|
395 #define PyUnicode_Check(op) PyObject_TypeCheck(op, &PyUnicode_Type) |
|
19849
bf0202dac441
Possibly the end of SF [#460020] bug or feature: unicode() and subclasses.
Tim Peters <tim.peters@gmail.com>
parents:
19589
diff
changeset
|
396 #define PyUnicode_CheckExact(op) ((op)->ob_type == &PyUnicode_Type) |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
397 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
398 /* Fast access macros */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
399 #define PyUnicode_GET_SIZE(op) \ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
400 (((PyUnicodeObject *)(op))->length) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
401 #define PyUnicode_GET_DATA_SIZE(op) \ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
402 (((PyUnicodeObject *)(op))->length * sizeof(Py_UNICODE)) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
403 #define PyUnicode_AS_UNICODE(op) \ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
404 (((PyUnicodeObject *)(op))->str) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
405 #define PyUnicode_AS_DATA(op) \ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
406 ((const char *)((PyUnicodeObject *)(op))->str) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
407 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
408 /* --- Constants ---------------------------------------------------------- */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
409 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
410 /* This Unicode character will be used as replacement character during |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
411 decoding if the errors argument is set to "replace". Note: the |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
412 Unicode character U+FFFD is the official REPLACEMENT CHARACTER in |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
413 Unicode 3.0. */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
414 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
415 #define Py_UNICODE_REPLACEMENT_CHARACTER ((Py_UNICODE) 0xFFFD) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
416 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
417 /* === Public API ========================================================= */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
418 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
419 /* --- Plain Py_UNICODE --------------------------------------------------- */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
420 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
421 /* Create a Unicode Object from the Py_UNICODE buffer u of the given |
|
17618
b44ba7c01217
This patch originated from an idea by Martin v. Loewis who submitted a
Marc-André Lemburg <mal@egenix.com>
parents:
13917
diff
changeset
|
422 size. |
|
b44ba7c01217
This patch originated from an idea by Martin v. Loewis who submitted a
Marc-André Lemburg <mal@egenix.com>
parents:
13917
diff
changeset
|
423 |
|
b44ba7c01217
This patch originated from an idea by Martin v. Loewis who submitted a
Marc-André Lemburg <mal@egenix.com>
parents:
13917
diff
changeset
|
424 u may be NULL which causes the contents to be undefined. It is the |
|
b44ba7c01217
This patch originated from an idea by Martin v. Loewis who submitted a
Marc-André Lemburg <mal@egenix.com>
parents:
13917
diff
changeset
|
425 user's responsibility to fill in the needed data afterwards. Note |
|
b44ba7c01217
This patch originated from an idea by Martin v. Loewis who submitted a
Marc-André Lemburg <mal@egenix.com>
parents:
13917
diff
changeset
|
426 that modifying the Unicode object contents after construction is |
|
b44ba7c01217
This patch originated from an idea by Martin v. Loewis who submitted a
Marc-André Lemburg <mal@egenix.com>
parents:
13917
diff
changeset
|
427 only allowed if u was set to NULL. |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
428 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
429 The buffer is copied into the new object. */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
430 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
431 PyAPI_FUNC(PyObject*) PyUnicode_FromUnicode( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
432 const Py_UNICODE *u, /* Unicode buffer */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
433 Py_ssize_t size /* size of buffer */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
434 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
435 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
436 /* Return a read-only pointer to the Unicode object's internal |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
437 Py_UNICODE buffer. */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
438 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
439 PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
440 PyObject *unicode /* Unicode object */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
441 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
442 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
443 /* Get the length of the Unicode object. */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
444 |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
445 PyAPI_FUNC(Py_ssize_t) PyUnicode_GetSize( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
446 PyObject *unicode /* Unicode object */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
447 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
448 |
|
18298
982163c4e9d2
Encode surrogates in UTF-8 even for a wide Py_UNICODE.
Martin v. Löwis <martin@v.loewis.de>
parents:
18296
diff
changeset
|
449 /* Get the maximum ordinal for a Unicode character. */ |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
450 PyAPI_FUNC(Py_UNICODE) PyUnicode_GetMax(void); |
|
18298
982163c4e9d2
Encode surrogates in UTF-8 even for a wide Py_UNICODE.
Martin v. Löwis <martin@v.loewis.de>
parents:
18296
diff
changeset
|
451 |
|
12326
9488e4fdafe4
Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents:
12248
diff
changeset
|
452 /* Resize an already allocated Unicode object to the new size length. |
|
9488e4fdafe4
Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents:
12248
diff
changeset
|
453 |
|
9488e4fdafe4
Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents:
12248
diff
changeset
|
454 *unicode is modified to point to the new (resized) object and 0 |
|
9488e4fdafe4
Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents:
12248
diff
changeset
|
455 returned on success. |
|
9488e4fdafe4
Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents:
12248
diff
changeset
|
456 |
|
9488e4fdafe4
Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents:
12248
diff
changeset
|
457 This API may only be called by the function which also called the |
|
9488e4fdafe4
Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents:
12248
diff
changeset
|
458 Unicode constructor. The refcount on the object must be 1. Otherwise, |
|
9488e4fdafe4
Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents:
12248
diff
changeset
|
459 an error is returned. |
|
9488e4fdafe4
Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents:
12248
diff
changeset
|
460 |
|
9488e4fdafe4
Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents:
12248
diff
changeset
|
461 Error handling is implemented as follows: an exception is set, -1 |
|
9488e4fdafe4
Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents:
12248
diff
changeset
|
462 is returned and *unicode left untouched. |
|
9488e4fdafe4
Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents:
12248
diff
changeset
|
463 |
|
9488e4fdafe4
Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents:
12248
diff
changeset
|
464 */ |
|
9488e4fdafe4
Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents:
12248
diff
changeset
|
465 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
466 PyAPI_FUNC(int) PyUnicode_Resize( |
|
12326
9488e4fdafe4
Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents:
12248
diff
changeset
|
467 PyObject **unicode, /* Pointer to the Unicode object */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
468 Py_ssize_t length /* New length */ |
|
12326
9488e4fdafe4
Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents:
12248
diff
changeset
|
469 ); |
|
9488e4fdafe4
Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents:
12248
diff
changeset
|
470 |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
471 /* Coerce obj to an Unicode object and return a reference with |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
472 *incremented* refcount. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
473 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
474 Coercion is done in the following way: |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
475 |
|
20554
0336ee5b46d4
SF patch #470578: Fixes to synchronize unicode() and str()
Guido van Rossum <guido@python.org>
parents:
19998
diff
changeset
|
476 1. String and other char buffer compatible objects are decoded |
|
12643
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
477 under the assumptions that they contain data using the current |
|
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
478 default encoding. Decoding is done in "strict" mode. |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
479 |
|
20554
0336ee5b46d4
SF patch #470578: Fixes to synchronize unicode() and str()
Guido van Rossum <guido@python.org>
parents:
19998
diff
changeset
|
480 2. All other objects (including Unicode objects) raise an |
|
0336ee5b46d4
SF patch #470578: Fixes to synchronize unicode() and str()
Guido van Rossum <guido@python.org>
parents:
19998
diff
changeset
|
481 exception. |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
482 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
483 The API returns NULL in case of an error. The caller is responsible |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
484 for decref'ing the returned objects. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
485 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
486 */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
487 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
488 PyAPI_FUNC(PyObject*) PyUnicode_FromEncodedObject( |
|
13401
8f1a2deeb9b0
Added new API PyUnicode_FromEncodedObject() which supports decoding
Marc-André Lemburg <mal@egenix.com>
parents:
13393
diff
changeset
|
489 register PyObject *obj, /* Object */ |
|
8f1a2deeb9b0
Added new API PyUnicode_FromEncodedObject() which supports decoding
Marc-André Lemburg <mal@egenix.com>
parents:
13393
diff
changeset
|
490 const char *encoding, /* encoding */ |
|
8f1a2deeb9b0
Added new API PyUnicode_FromEncodedObject() which supports decoding
Marc-André Lemburg <mal@egenix.com>
parents:
13393
diff
changeset
|
491 const char *errors /* error handling */ |
|
8f1a2deeb9b0
Added new API PyUnicode_FromEncodedObject() which supports decoding
Marc-André Lemburg <mal@egenix.com>
parents:
13393
diff
changeset
|
492 ); |
|
8f1a2deeb9b0
Added new API PyUnicode_FromEncodedObject() which supports decoding
Marc-André Lemburg <mal@egenix.com>
parents:
13393
diff
changeset
|
493 |
|
20554
0336ee5b46d4
SF patch #470578: Fixes to synchronize unicode() and str()
Guido van Rossum <guido@python.org>
parents:
19998
diff
changeset
|
494 /* Coerce obj to an Unicode object and return a reference with |
|
13401
8f1a2deeb9b0
Added new API PyUnicode_FromEncodedObject() which supports decoding
Marc-André Lemburg <mal@egenix.com>
parents:
13393
diff
changeset
|
495 *incremented* refcount. |
|
20554
0336ee5b46d4
SF patch #470578: Fixes to synchronize unicode() and str()
Guido van Rossum <guido@python.org>
parents:
19998
diff
changeset
|
496 |
|
0336ee5b46d4
SF patch #470578: Fixes to synchronize unicode() and str()
Guido van Rossum <guido@python.org>
parents:
19998
diff
changeset
|
497 Unicode objects are passed back as-is (subclasses are converted to |
|
0336ee5b46d4
SF patch #470578: Fixes to synchronize unicode() and str()
Guido van Rossum <guido@python.org>
parents:
19998
diff
changeset
|
498 true Unicode objects), all other objects are delegated to |
|
0336ee5b46d4
SF patch #470578: Fixes to synchronize unicode() and str()
Guido van Rossum <guido@python.org>
parents:
19998
diff
changeset
|
499 PyUnicode_FromEncodedObject(obj, NULL, "strict") which results in |
|
0336ee5b46d4
SF patch #470578: Fixes to synchronize unicode() and str()
Guido van Rossum <guido@python.org>
parents:
19998
diff
changeset
|
500 using the default encoding as basis for decoding the object. |
|
13401
8f1a2deeb9b0
Added new API PyUnicode_FromEncodedObject() which supports decoding
Marc-André Lemburg <mal@egenix.com>
parents:
13393
diff
changeset
|
501 |
|
8f1a2deeb9b0
Added new API PyUnicode_FromEncodedObject() which supports decoding
Marc-André Lemburg <mal@egenix.com>
parents:
13393
diff
changeset
|
502 The API returns NULL in case of an error. The caller is responsible |
|
8f1a2deeb9b0
Added new API PyUnicode_FromEncodedObject() which supports decoding
Marc-André Lemburg <mal@egenix.com>
parents:
13393
diff
changeset
|
503 for decref'ing the returned objects. |
|
8f1a2deeb9b0
Added new API PyUnicode_FromEncodedObject() which supports decoding
Marc-André Lemburg <mal@egenix.com>
parents:
13393
diff
changeset
|
504 |
|
8f1a2deeb9b0
Added new API PyUnicode_FromEncodedObject() which supports decoding
Marc-André Lemburg <mal@egenix.com>
parents:
13393
diff
changeset
|
505 */ |
|
8f1a2deeb9b0
Added new API PyUnicode_FromEncodedObject() which supports decoding
Marc-André Lemburg <mal@egenix.com>
parents:
13393
diff
changeset
|
506 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
507 PyAPI_FUNC(PyObject*) PyUnicode_FromObject( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
508 register PyObject *obj /* Object */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
509 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
510 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
511 /* --- wchar_t support for platforms which support it --------------------- */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
512 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
513 #ifdef HAVE_WCHAR_H |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
514 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
515 /* Create a Unicode Object from the whcar_t buffer w of the given |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
516 size. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
517 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
518 The buffer is copied into the new object. */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
519 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
520 PyAPI_FUNC(PyObject*) PyUnicode_FromWideChar( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
521 register const wchar_t *w, /* wchar_t buffer */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
522 Py_ssize_t size /* size of buffer */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
523 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
524 |
|
34016
264e45baacd5
Correct the handling of 0-termination of PyUnicode_AsWideChar()
Marc-André Lemburg <mal@egenix.com>
parents:
33864
diff
changeset
|
525 /* Copies the Unicode Object contents into the wchar_t buffer w. At |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
526 most size wchar_t characters are copied. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
527 |
|
34016
264e45baacd5
Correct the handling of 0-termination of PyUnicode_AsWideChar()
Marc-André Lemburg <mal@egenix.com>
parents:
33864
diff
changeset
|
528 Note that the resulting wchar_t string may or may not be |
|
264e45baacd5
Correct the handling of 0-termination of PyUnicode_AsWideChar()
Marc-André Lemburg <mal@egenix.com>
parents:
33864
diff
changeset
|
529 0-terminated. It is the responsibility of the caller to make sure |
|
264e45baacd5
Correct the handling of 0-termination of PyUnicode_AsWideChar()
Marc-André Lemburg <mal@egenix.com>
parents:
33864
diff
changeset
|
530 that the wchar_t string is 0-terminated in case this is required by |
|
264e45baacd5
Correct the handling of 0-termination of PyUnicode_AsWideChar()
Marc-André Lemburg <mal@egenix.com>
parents:
33864
diff
changeset
|
531 the application. |
|
264e45baacd5
Correct the handling of 0-termination of PyUnicode_AsWideChar()
Marc-André Lemburg <mal@egenix.com>
parents:
33864
diff
changeset
|
532 |
|
264e45baacd5
Correct the handling of 0-termination of PyUnicode_AsWideChar()
Marc-André Lemburg <mal@egenix.com>
parents:
33864
diff
changeset
|
533 Returns the number of wchar_t characters copied (excluding a |
|
264e45baacd5
Correct the handling of 0-termination of PyUnicode_AsWideChar()
Marc-André Lemburg <mal@egenix.com>
parents:
33864
diff
changeset
|
534 possibly trailing 0-termination character) or -1 in case of an |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
535 error. */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
536 |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
537 PyAPI_FUNC(Py_ssize_t) PyUnicode_AsWideChar( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
538 PyUnicodeObject *unicode, /* Unicode object */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
539 register wchar_t *w, /* wchar_t buffer */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
540 Py_ssize_t size /* size of buffer */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
541 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
542 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
543 #endif |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
544 |
|
24737
eaa87632b1e8
Add C API PyUnicode_FromOrdinal() which exposes unichr() at C level.
Marc-André Lemburg <mal@egenix.com>
parents:
23561
diff
changeset
|
545 /* --- Unicode ordinals --------------------------------------------------- */ |
|
eaa87632b1e8
Add C API PyUnicode_FromOrdinal() which exposes unichr() at C level.
Marc-André Lemburg <mal@egenix.com>
parents:
23561
diff
changeset
|
546 |
|
eaa87632b1e8
Add C API PyUnicode_FromOrdinal() which exposes unichr() at C level.
Marc-André Lemburg <mal@egenix.com>
parents:
23561
diff
changeset
|
547 /* Create a Unicode Object from the given Unicode code point ordinal. |
|
eaa87632b1e8
Add C API PyUnicode_FromOrdinal() which exposes unichr() at C level.
Marc-André Lemburg <mal@egenix.com>
parents:
23561
diff
changeset
|
548 |
|
eaa87632b1e8
Add C API PyUnicode_FromOrdinal() which exposes unichr() at C level.
Marc-André Lemburg <mal@egenix.com>
parents:
23561
diff
changeset
|
549 The ordinal must be in range(0x10000) on narrow Python builds |
|
eaa87632b1e8
Add C API PyUnicode_FromOrdinal() which exposes unichr() at C level.
Marc-André Lemburg <mal@egenix.com>
parents:
23561
diff
changeset
|
550 (UCS2), and range(0x110000) on wide builds (UCS4). A ValueError is |
|
eaa87632b1e8
Add C API PyUnicode_FromOrdinal() which exposes unichr() at C level.
Marc-André Lemburg <mal@egenix.com>
parents:
23561
diff
changeset
|
551 raised in case it is not. |
|
eaa87632b1e8
Add C API PyUnicode_FromOrdinal() which exposes unichr() at C level.
Marc-André Lemburg <mal@egenix.com>
parents:
23561
diff
changeset
|
552 |
|
eaa87632b1e8
Add C API PyUnicode_FromOrdinal() which exposes unichr() at C level.
Marc-André Lemburg <mal@egenix.com>
parents:
23561
diff
changeset
|
553 */ |
|
eaa87632b1e8
Add C API PyUnicode_FromOrdinal() which exposes unichr() at C level.
Marc-André Lemburg <mal@egenix.com>
parents:
23561
diff
changeset
|
554 |
|
24753
27ae978bee58
Add name mangling for new PyUnicode_FromOrdinal() and fix declaration
Marc-André Lemburg <mal@egenix.com>
parents:
24752
diff
changeset
|
555 PyAPI_FUNC(PyObject*) PyUnicode_FromOrdinal(int ordinal); |
|
24737
eaa87632b1e8
Add C API PyUnicode_FromOrdinal() which exposes unichr() at C level.
Marc-André Lemburg <mal@egenix.com>
parents:
23561
diff
changeset
|
556 |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
557 /* === Builtin Codecs ===================================================== |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
558 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
559 Many of these APIs take two arguments encoding and errors. These |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
560 parameters encoding and errors have the same semantics as the ones |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
561 of the builtin unicode() API. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
562 |
|
12643
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
563 Setting encoding to NULL causes the default encoding to be used. |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
564 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
565 Error handling is set by errors which may also be set to NULL |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
566 meaning to use the default handling defined for the codec. Default |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
567 error handling for all builtin codecs is "strict" (ValueErrors are |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
568 raised). |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
569 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
570 The codecs all use a similar interface. Only deviation from the |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
571 generic ones are documented. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
572 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
573 */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
574 |
|
12643
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
575 /* --- Manage the default encoding ---------------------------------------- */ |
|
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
576 |
|
18887
9b291ca6546c
Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18332
diff
changeset
|
577 /* Return a Python string holding the default encoded value of the |
|
9b291ca6546c
Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18332
diff
changeset
|
578 Unicode object. |
|
9b291ca6546c
Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18332
diff
changeset
|
579 |
|
9b291ca6546c
Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18332
diff
changeset
|
580 The resulting string is cached in the Unicode object for subsequent |
|
9b291ca6546c
Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18332
diff
changeset
|
581 usage by this function. The cached version is needed to implement |
|
9b291ca6546c
Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18332
diff
changeset
|
582 the character buffer interface and will live (at least) as long as |
|
9b291ca6546c
Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18332
diff
changeset
|
583 the Unicode object itself. |
|
9b291ca6546c
Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18332
diff
changeset
|
584 |
|
9b291ca6546c
Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18332
diff
changeset
|
585 The refcount of the string is *not* incremented. |
|
9b291ca6546c
Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18332
diff
changeset
|
586 |
|
9b291ca6546c
Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18332
diff
changeset
|
587 *** Exported for internal use by the interpreter only !!! *** |
|
9b291ca6546c
Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18332
diff
changeset
|
588 |
|
9b291ca6546c
Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18332
diff
changeset
|
589 */ |
|
9b291ca6546c
Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18332
diff
changeset
|
590 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
591 PyAPI_FUNC(PyObject *) _PyUnicode_AsDefaultEncodedString( |
|
18887
9b291ca6546c
Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18332
diff
changeset
|
592 PyObject *, const char *); |
|
9b291ca6546c
Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18332
diff
changeset
|
593 |
|
12643
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
594 /* Returns the currently active default encoding. |
|
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
595 |
|
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
596 The default encoding is currently implemented as run-time settable |
|
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
597 process global. This may change in future versions of the |
|
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
598 interpreter to become a parameter which is managed on a per-thread |
|
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
599 basis. |
|
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
600 |
|
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
601 */ |
|
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
602 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
603 PyAPI_FUNC(const char*) PyUnicode_GetDefaultEncoding(void); |
|
12643
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
604 |
|
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
605 /* Sets the currently active default encoding. |
|
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
606 |
|
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
607 Returns 0 on success, -1 in case of an error. |
|
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
608 |
|
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
609 */ |
|
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
610 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
611 PyAPI_FUNC(int) PyUnicode_SetDefaultEncoding( |
|
12643
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
612 const char *encoding /* Encoding name in standard form */ |
|
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
613 ); |
|
06ff966f69d5
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12372
diff
changeset
|
614 |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
615 /* --- Generic Codecs ----------------------------------------------------- */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
616 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
617 /* Create a Unicode object by decoding the encoded string s of the |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
618 given size. */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
619 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
620 PyAPI_FUNC(PyObject*) PyUnicode_Decode( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
621 const char *s, /* encoded string */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
622 Py_ssize_t size, /* size of buffer */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
623 const char *encoding, /* encoding */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
624 const char *errors /* error handling */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
625 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
626 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
627 /* Encodes a Py_UNICODE buffer of the given size and returns a |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
628 Python string object. */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
629 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
630 PyAPI_FUNC(PyObject*) PyUnicode_Encode( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
631 const Py_UNICODE *s, /* Unicode char buffer */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
632 Py_ssize_t size, /* number of Py_UNICODE chars to encode */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
633 const char *encoding, /* encoding */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
634 const char *errors /* error handling */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
635 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
636 |
|
32551
f46d49e2e0f0
Allow string and unicode return types from .encode()/.decode()
Marc-André Lemburg <mal@egenix.com>
parents:
32197
diff
changeset
|
637 /* Encodes a Unicode object and returns the result as Python |
|
f46d49e2e0f0
Allow string and unicode return types from .encode()/.decode()
Marc-André Lemburg <mal@egenix.com>
parents:
32197
diff
changeset
|
638 object. */ |
|
f46d49e2e0f0
Allow string and unicode return types from .encode()/.decode()
Marc-André Lemburg <mal@egenix.com>
parents:
32197
diff
changeset
|
639 |
|
f46d49e2e0f0
Allow string and unicode return types from .encode()/.decode()
Marc-André Lemburg <mal@egenix.com>
parents:
32197
diff
changeset
|
640 PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedObject( |
|
f46d49e2e0f0
Allow string and unicode return types from .encode()/.decode()
Marc-André Lemburg <mal@egenix.com>
parents:
32197
diff
changeset
|
641 PyObject *unicode, /* Unicode object */ |
|
f46d49e2e0f0
Allow string and unicode return types from .encode()/.decode()
Marc-André Lemburg <mal@egenix.com>
parents:
32197
diff
changeset
|
642 const char *encoding, /* encoding */ |
|
f46d49e2e0f0
Allow string and unicode return types from .encode()/.decode()
Marc-André Lemburg <mal@egenix.com>
parents:
32197
diff
changeset
|
643 const char *errors /* error handling */ |
|
f46d49e2e0f0
Allow string and unicode return types from .encode()/.decode()
Marc-André Lemburg <mal@egenix.com>
parents:
32197
diff
changeset
|
644 ); |
|
f46d49e2e0f0
Allow string and unicode return types from .encode()/.decode()
Marc-André Lemburg <mal@egenix.com>
parents:
32197
diff
changeset
|
645 |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
646 /* Encodes a Unicode object and returns the result as Python string |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
647 object. */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
648 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
649 PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedString( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
650 PyObject *unicode, /* Unicode object */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
651 const char *encoding, /* encoding */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
652 const char *errors /* error handling */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
653 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
654 |
|
38586
9e0b050ce46f
Patch #1359618: Speed-up charmap encoder.
Martin v. Löwis <martin@v.loewis.de>
parents:
38457
diff
changeset
|
655 PyAPI_FUNC(PyObject*) PyUnicode_BuildEncodingMap( |
|
9e0b050ce46f
Patch #1359618: Speed-up charmap encoder.
Martin v. Löwis <martin@v.loewis.de>
parents:
38457
diff
changeset
|
656 PyObject* string /* 256 character map */ |
|
9e0b050ce46f
Patch #1359618: Speed-up charmap encoder.
Martin v. Löwis <martin@v.loewis.de>
parents:
38457
diff
changeset
|
657 ); |
|
9e0b050ce46f
Patch #1359618: Speed-up charmap encoder.
Martin v. Löwis <martin@v.loewis.de>
parents:
38457
diff
changeset
|
658 |
|
9e0b050ce46f
Patch #1359618: Speed-up charmap encoder.
Martin v. Löwis <martin@v.loewis.de>
parents:
38457
diff
changeset
|
659 |
|
19998
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19980
diff
changeset
|
660 /* --- UTF-7 Codecs ------------------------------------------------------- */ |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19980
diff
changeset
|
661 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
662 PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF7( |
|
19998
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19980
diff
changeset
|
663 const char *string, /* UTF-7 encoded string */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
664 Py_ssize_t length, /* size of string */ |
|
19998
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19980
diff
changeset
|
665 const char *errors /* error handling */ |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19980
diff
changeset
|
666 ); |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19980
diff
changeset
|
667 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
668 PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF7( |
|
19998
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19980
diff
changeset
|
669 const Py_UNICODE *data, /* Unicode char buffer */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
670 Py_ssize_t length, /* number of Py_UNICODE chars to encode */ |
|
19998
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19980
diff
changeset
|
671 int encodeSetO, /* force the encoder to encode characters in |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19980
diff
changeset
|
672 Set O, as described in RFC2152 */ |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19980
diff
changeset
|
673 int encodeWhiteSpace, /* force the encoder to encode space, tab, |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19980
diff
changeset
|
674 carriage return and linefeed characters */ |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19980
diff
changeset
|
675 const char *errors /* error handling */ |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19980
diff
changeset
|
676 ); |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19980
diff
changeset
|
677 |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
678 /* --- UTF-8 Codecs ------------------------------------------------------- */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
679 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
680 PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF8( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
681 const char *string, /* UTF-8 encoded string */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
682 Py_ssize_t length, /* size of string */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
683 const char *errors /* error handling */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
684 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
685 |
|
33428
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
686 PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF8Stateful( |
|
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
687 const char *string, /* UTF-8 encoded string */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
688 Py_ssize_t length, /* size of string */ |
|
33428
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
689 const char *errors, /* error handling */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
690 Py_ssize_t *consumed /* bytes consumed */ |
|
33428
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
691 ); |
|
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
692 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
693 PyAPI_FUNC(PyObject*) PyUnicode_AsUTF8String( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
694 PyObject *unicode /* Unicode object */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
695 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
696 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
697 PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF8( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
698 const Py_UNICODE *data, /* Unicode char buffer */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
699 Py_ssize_t length, /* number of Py_UNICODE chars to encode */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
700 const char *errors /* error handling */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
701 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
702 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
703 /* --- UTF-16 Codecs ------------------------------------------------------ */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
704 |
|
12248
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
705 /* Decodes length bytes from a UTF-16 encoded buffer string and returns |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
706 the corresponding Unicode object. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
707 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
708 errors (if non-NULL) defines the error handling. It defaults |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
709 to "strict". |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
710 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
711 If byteorder is non-NULL, the decoder starts decoding using the |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
712 given byte order: |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
713 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
714 *byteorder == -1: little endian |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
715 *byteorder == 0: native order |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
716 *byteorder == 1: big endian |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
717 |
|
17887
fd5f83188778
This patch changes the behaviour of the UTF-16 codec family. Only the
Marc-André Lemburg <mal@egenix.com>
parents:
17618
diff
changeset
|
718 In native mode, the first two bytes of the stream are checked for a |
|
fd5f83188778
This patch changes the behaviour of the UTF-16 codec family. Only the
Marc-André Lemburg <mal@egenix.com>
parents:
17618
diff
changeset
|
719 BOM mark. If found, the BOM mark is analysed, the byte order |
|
fd5f83188778
This patch changes the behaviour of the UTF-16 codec family. Only the
Marc-André Lemburg <mal@egenix.com>
parents:
17618
diff
changeset
|
720 adjusted and the BOM skipped. In the other modes, no BOM mark |
|
fd5f83188778
This patch changes the behaviour of the UTF-16 codec family. Only the
Marc-André Lemburg <mal@egenix.com>
parents:
17618
diff
changeset
|
721 interpretation is done. After completion, *byteorder is set to the |
|
fd5f83188778
This patch changes the behaviour of the UTF-16 codec family. Only the
Marc-André Lemburg <mal@egenix.com>
parents:
17618
diff
changeset
|
722 current byte order at the end of input data. |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
723 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
724 If byteorder is NULL, the codec starts in native order mode. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
725 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
726 */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
727 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
728 PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF16( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
729 const char *string, /* UTF-16 encoded string */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
730 Py_ssize_t length, /* size of string */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
731 const char *errors, /* error handling */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
732 int *byteorder /* pointer to byteorder to use |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
733 0=native;-1=LE,1=BE; updated on |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
734 exit */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
735 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
736 |
|
33428
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
737 PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF16Stateful( |
|
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
738 const char *string, /* UTF-16 encoded string */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
739 Py_ssize_t length, /* size of string */ |
|
33428
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
740 const char *errors, /* error handling */ |
|
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
741 int *byteorder, /* pointer to byteorder to use |
|
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
742 0=native;-1=LE,1=BE; updated on |
|
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
743 exit */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
744 Py_ssize_t *consumed /* bytes consumed */ |
|
33428
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
745 ); |
|
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
746 |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
747 /* Returns a Python string using the UTF-16 encoding in native byte |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
748 order. The string always starts with a BOM mark. */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
749 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
750 PyAPI_FUNC(PyObject*) PyUnicode_AsUTF16String( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
751 PyObject *unicode /* Unicode object */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
752 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
753 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
754 /* Returns a Python string object holding the UTF-16 encoded value of |
|
12248
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
755 the Unicode data. |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
756 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
757 If byteorder is not 0, output is written according to the following |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
758 byte order: |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
759 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
760 byteorder == -1: little endian |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
761 byteorder == 0: native byte order (writes a BOM mark) |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
762 byteorder == 1: big endian |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
763 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
764 If byteorder is 0, the output string will always start with the |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
765 Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
766 prepended. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
767 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
768 Note that Py_UNICODE data is being interpreted as UTF-16 reduced to |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
769 UCS-2. This trick makes it possible to add full UTF-16 capabilities |
|
13620
5b727ab37092
Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in either
Thomas Wouters <thomas@python.org>
parents:
13401
diff
changeset
|
770 at a later point without compromising the APIs. |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
771 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
772 */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
773 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
774 PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF16( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
775 const Py_UNICODE *data, /* Unicode char buffer */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
776 Py_ssize_t length, /* number of Py_UNICODE chars to encode */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
777 const char *errors, /* error handling */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
778 int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
779 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
780 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
781 /* --- Unicode-Escape Codecs ---------------------------------------------- */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
782 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
783 PyAPI_FUNC(PyObject*) PyUnicode_DecodeUnicodeEscape( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
784 const char *string, /* Unicode-Escape encoded string */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
785 Py_ssize_t length, /* size of string */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
786 const char *errors /* error handling */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
787 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
788 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
789 PyAPI_FUNC(PyObject*) PyUnicode_AsUnicodeEscapeString( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
790 PyObject *unicode /* Unicode object */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
791 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
792 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
793 PyAPI_FUNC(PyObject*) PyUnicode_EncodeUnicodeEscape( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
794 const Py_UNICODE *data, /* Unicode char buffer */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
795 Py_ssize_t length /* Number of Py_UNICODE chars to encode */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
796 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
797 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
798 /* --- Raw-Unicode-Escape Codecs ------------------------------------------ */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
799 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
800 PyAPI_FUNC(PyObject*) PyUnicode_DecodeRawUnicodeEscape( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
801 const char *string, /* Raw-Unicode-Escape encoded string */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
802 Py_ssize_t length, /* size of string */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
803 const char *errors /* error handling */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
804 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
805 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
806 PyAPI_FUNC(PyObject*) PyUnicode_AsRawUnicodeEscapeString( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
807 PyObject *unicode /* Unicode object */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
808 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
809 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
810 PyAPI_FUNC(PyObject*) PyUnicode_EncodeRawUnicodeEscape( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
811 const Py_UNICODE *data, /* Unicode char buffer */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
812 Py_ssize_t length /* Number of Py_UNICODE chars to encode */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
813 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
814 |
| 35485 | 815 /* --- Unicode Internal Codec --------------------------------------------- |
| 816 | |
| 817 Only for internal use in _codecsmodule.c */ | |
| 818 | |
| 819 PyObject *_PyUnicode_DecodeUnicodeInternal( | |
| 820 const char *string, | |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
821 Py_ssize_t length, |
| 35485 | 822 const char *errors |
| 823 ); | |
| 824 | |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
825 /* --- Latin-1 Codecs ----------------------------------------------------- |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
826 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
827 Note: Latin-1 corresponds to the first 256 Unicode ordinals. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
828 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
829 */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
830 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
831 PyAPI_FUNC(PyObject*) PyUnicode_DecodeLatin1( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
832 const char *string, /* Latin-1 encoded string */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
833 Py_ssize_t length, /* size of string */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
834 const char *errors /* error handling */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
835 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
836 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
837 PyAPI_FUNC(PyObject*) PyUnicode_AsLatin1String( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
838 PyObject *unicode /* Unicode object */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
839 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
840 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
841 PyAPI_FUNC(PyObject*) PyUnicode_EncodeLatin1( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
842 const Py_UNICODE *data, /* Unicode char buffer */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
843 Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
844 const char *errors /* error handling */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
845 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
846 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
847 /* --- ASCII Codecs ------------------------------------------------------- |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
848 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
849 Only 7-bit ASCII data is excepted. All other codes generate errors. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
850 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
851 */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
852 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
853 PyAPI_FUNC(PyObject*) PyUnicode_DecodeASCII( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
854 const char *string, /* ASCII encoded string */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
855 Py_ssize_t length, /* size of string */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
856 const char *errors /* error handling */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
857 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
858 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
859 PyAPI_FUNC(PyObject*) PyUnicode_AsASCIIString( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
860 PyObject *unicode /* Unicode object */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
861 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
862 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
863 PyAPI_FUNC(PyObject*) PyUnicode_EncodeASCII( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
864 const Py_UNICODE *data, /* Unicode char buffer */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
865 Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
866 const char *errors /* error handling */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
867 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
868 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
869 /* --- Character Map Codecs ----------------------------------------------- |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
870 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
871 This codec uses mappings to encode and decode characters. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
872 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
873 Decoding mappings must map single string characters to single |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
874 Unicode characters, integers (which are then interpreted as Unicode |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
875 ordinals) or None (meaning "undefined mapping" and causing an |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
876 error). |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
877 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
878 Encoding mappings must map single Unicode characters to single |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
879 string characters, integers (which are then interpreted as Latin-1 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
880 ordinals) or None (meaning "undefined mapping" and causing an |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
881 error). |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
882 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
883 If a character lookup fails with a LookupError, the character is |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
884 copied as-is meaning that its ordinal value will be interpreted as |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
885 Unicode or Latin-1 ordinal resp. Because of this mappings only need |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
886 to contain those mappings which map characters to different code |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
887 points. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
888 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
889 */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
890 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
891 PyAPI_FUNC(PyObject*) PyUnicode_DecodeCharmap( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
892 const char *string, /* Encoded string */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
893 Py_ssize_t length, /* size of string */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
894 PyObject *mapping, /* character mapping |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
895 (char ordinal -> unicode ordinal) */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
896 const char *errors /* error handling */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
897 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
898 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
899 PyAPI_FUNC(PyObject*) PyUnicode_AsCharmapString( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
900 PyObject *unicode, /* Unicode object */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
901 PyObject *mapping /* character mapping |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
902 (unicode ordinal -> char ordinal) */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
903 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
904 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
905 PyAPI_FUNC(PyObject*) PyUnicode_EncodeCharmap( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
906 const Py_UNICODE *data, /* Unicode char buffer */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
907 Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
908 PyObject *mapping, /* character mapping |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
909 (unicode ordinal -> char ordinal) */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
910 const char *errors /* error handling */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
911 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
912 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
913 /* Translate a Py_UNICODE buffer of the given length by applying a |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
914 character mapping table to it and return the resulting Unicode |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
915 object. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
916 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
917 The mapping table must map Unicode ordinal integers to Unicode |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
918 ordinal integers or None (causing deletion of the character). |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
919 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
920 Mapping tables may be dictionaries or sequences. Unmapped character |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
921 ordinals (ones which cause a LookupError) are left untouched and |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
922 are copied as-is. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
923 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
924 */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
925 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
926 PyAPI_FUNC(PyObject *) PyUnicode_TranslateCharmap( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
927 const Py_UNICODE *data, /* Unicode char buffer */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
928 Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
929 PyObject *table, /* Translate table */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
930 const char *errors /* error handling */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
931 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
932 |
|
12066
86cffe50fb17
Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents:
12025
diff
changeset
|
933 #ifdef MS_WIN32 |
| 12074 | 934 |
|
12066
86cffe50fb17
Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents:
12025
diff
changeset
|
935 /* --- MBCS codecs for Windows -------------------------------------------- */ |
| 12074 | 936 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
937 PyAPI_FUNC(PyObject*) PyUnicode_DecodeMBCS( |
|
12066
86cffe50fb17
Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents:
12025
diff
changeset
|
938 const char *string, /* MBCS encoded string */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
939 Py_ssize_t length, /* size of string */ |
|
12066
86cffe50fb17
Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents:
12025
diff
changeset
|
940 const char *errors /* error handling */ |
|
86cffe50fb17
Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents:
12025
diff
changeset
|
941 ); |
|
86cffe50fb17
Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents:
12025
diff
changeset
|
942 |
|
38817
549c547700af
Patch #1455898: Incremental mode for "mbcs" codec.
Martin v. Löwis <martin@v.loewis.de>
parents:
38586
diff
changeset
|
943 PyAPI_FUNC(PyObject*) PyUnicode_DecodeMBCSStateful( |
|
549c547700af
Patch #1455898: Incremental mode for "mbcs" codec.
Martin v. Löwis <martin@v.loewis.de>
parents:
38586
diff
changeset
|
944 const char *string, /* MBCS encoded string */ |
|
549c547700af
Patch #1455898: Incremental mode for "mbcs" codec.
Martin v. Löwis <martin@v.loewis.de>
parents:
38586
diff
changeset
|
945 Py_ssize_t length, /* size of string */ |
|
549c547700af
Patch #1455898: Incremental mode for "mbcs" codec.
Martin v. Löwis <martin@v.loewis.de>
parents:
38586
diff
changeset
|
946 const char *errors, /* error handling */ |
|
549c547700af
Patch #1455898: Incremental mode for "mbcs" codec.
Martin v. Löwis <martin@v.loewis.de>
parents:
38586
diff
changeset
|
947 Py_ssize_t *consumed /* bytes consumed */ |
|
549c547700af
Patch #1455898: Incremental mode for "mbcs" codec.
Martin v. Löwis <martin@v.loewis.de>
parents:
38586
diff
changeset
|
948 ); |
|
549c547700af
Patch #1455898: Incremental mode for "mbcs" codec.
Martin v. Löwis <martin@v.loewis.de>
parents:
38586
diff
changeset
|
949 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
950 PyAPI_FUNC(PyObject*) PyUnicode_AsMBCSString( |
|
12066
86cffe50fb17
Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents:
12025
diff
changeset
|
951 PyObject *unicode /* Unicode object */ |
|
86cffe50fb17
Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents:
12025
diff
changeset
|
952 ); |
|
86cffe50fb17
Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents:
12025
diff
changeset
|
953 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
954 PyAPI_FUNC(PyObject*) PyUnicode_EncodeMBCS( |
|
12066
86cffe50fb17
Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents:
12025
diff
changeset
|
955 const Py_UNICODE *data, /* Unicode char buffer */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
956 Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ |
|
12066
86cffe50fb17
Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents:
12025
diff
changeset
|
957 const char *errors /* error handling */ |
|
86cffe50fb17
Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents:
12025
diff
changeset
|
958 ); |
|
86cffe50fb17
Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents:
12025
diff
changeset
|
959 |
| 12074 | 960 #endif /* MS_WIN32 */ |
|
12066
86cffe50fb17
Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents:
12025
diff
changeset
|
961 |
|
12248
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
962 /* --- Decimal Encoder ---------------------------------------------------- */ |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
963 |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
964 /* Takes a Unicode string holding a decimal value and writes it into |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
965 an output buffer using standard ASCII digit codes. |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
966 |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
967 The output buffer has to provide at least length+1 bytes of storage |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
968 area. The output string is 0-terminated. |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
969 |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
970 The encoder converts whitespace to ' ', decimal characters to their |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
971 corresponding ASCII digit and all other Latin-1 characters except |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
972 \0 as-is. Characters outside this range (Unicode ordinals 1-256) |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
973 are treated as errors. This includes embedded NULL bytes. |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
974 |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
975 Error handling is defined by the errors argument: |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
976 |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
977 NULL or "strict": raise a ValueError |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
978 "ignore": ignore the wrong characters (these are not copied to the |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
979 output buffer) |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
980 "replace": replaces illegal characters with '?' |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
981 |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
982 Returns 0 on success, -1 on failure. |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
983 |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
984 */ |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
985 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
986 PyAPI_FUNC(int) PyUnicode_EncodeDecimal( |
|
12248
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
987 Py_UNICODE *s, /* Unicode buffer */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
988 Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ |
|
12248
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
989 char *output, /* Output buffer; must have size >= length */ |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
990 const char *errors /* error handling */ |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
991 ); |
|
70154e2e9c89
Marc-Andre's third try at this bulk patch seems to work (except that
Guido van Rossum <guido@python.org>
parents:
12074
diff
changeset
|
992 |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
993 /* --- Methods & Slots ---------------------------------------------------- |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
994 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
995 These are capable of handling Unicode objects and strings on input |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
996 (we refer to them as strings in the descriptions) and return |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
997 Unicode objects or integers as apporpriate. */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
998 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
999 /* Concat two strings giving a new Unicode string. */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1000 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1001 PyAPI_FUNC(PyObject*) PyUnicode_Concat( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1002 PyObject *left, /* Left string */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1003 PyObject *right /* Right string */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1004 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1005 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1006 /* Split a string giving a list of Unicode strings. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1007 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1008 If sep is NULL, splitting will be done at all whitespace |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1009 substrings. Otherwise, splits occur at the given separator. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1010 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1011 At most maxsplit splits will be done. If negative, no limit is set. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1012 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1013 Separators are not included in the resulting list. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1014 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1015 */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1016 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1017 PyAPI_FUNC(PyObject*) PyUnicode_Split( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1018 PyObject *s, /* String to split */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1019 PyObject *sep, /* String separator */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
1020 Py_ssize_t maxsplit /* Maxsplit count */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1021 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1022 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1023 /* Dito, but split at line breaks. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1024 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1025 CRLF is considered to be one line break. Line breaks are not |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1026 included in the resulting list. */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1027 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1028 PyAPI_FUNC(PyObject*) PyUnicode_Splitlines( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1029 PyObject *s, /* String to split */ |
| 12372 | 1030 int keepends /* If true, line end markers are included */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1031 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1032 |
|
38335
f9332ad4287a
needforspeed: partition implementation, part two.
Fredrik Lundh <fredrik@pythonware.com>
parents:
38242
diff
changeset
|
1033 /* Partition a string using a given separator. */ |
|
f9332ad4287a
needforspeed: partition implementation, part two.
Fredrik Lundh <fredrik@pythonware.com>
parents:
38242
diff
changeset
|
1034 |
|
f9332ad4287a
needforspeed: partition implementation, part two.
Fredrik Lundh <fredrik@pythonware.com>
parents:
38242
diff
changeset
|
1035 PyAPI_FUNC(PyObject*) PyUnicode_Partition( |
|
f9332ad4287a
needforspeed: partition implementation, part two.
Fredrik Lundh <fredrik@pythonware.com>
parents:
38242
diff
changeset
|
1036 PyObject *s, /* String to partition */ |
|
f9332ad4287a
needforspeed: partition implementation, part two.
Fredrik Lundh <fredrik@pythonware.com>
parents:
38242
diff
changeset
|
1037 PyObject *sep /* String separator */ |
|
f9332ad4287a
needforspeed: partition implementation, part two.
Fredrik Lundh <fredrik@pythonware.com>
parents:
38242
diff
changeset
|
1038 ); |
|
f9332ad4287a
needforspeed: partition implementation, part two.
Fredrik Lundh <fredrik@pythonware.com>
parents:
38242
diff
changeset
|
1039 |
|
38390
76807902a2f5
needforspeed: added rpartition implementation
Fredrik Lundh <fredrik@pythonware.com>
parents:
38335
diff
changeset
|
1040 /* Partition a string using a given separator, searching from the end of the |
|
76807902a2f5
needforspeed: added rpartition implementation
Fredrik Lundh <fredrik@pythonware.com>
parents:
38335
diff
changeset
|
1041 string. */ |
|
76807902a2f5
needforspeed: added rpartition implementation
Fredrik Lundh <fredrik@pythonware.com>
parents:
38335
diff
changeset
|
1042 |
|
76807902a2f5
needforspeed: added rpartition implementation
Fredrik Lundh <fredrik@pythonware.com>
parents:
38335
diff
changeset
|
1043 PyAPI_FUNC(PyObject*) PyUnicode_RPartition( |
|
76807902a2f5
needforspeed: added rpartition implementation
Fredrik Lundh <fredrik@pythonware.com>
parents:
38335
diff
changeset
|
1044 PyObject *s, /* String to partition */ |
|
76807902a2f5
needforspeed: added rpartition implementation
Fredrik Lundh <fredrik@pythonware.com>
parents:
38335
diff
changeset
|
1045 PyObject *sep /* String separator */ |
|
76807902a2f5
needforspeed: added rpartition implementation
Fredrik Lundh <fredrik@pythonware.com>
parents:
38335
diff
changeset
|
1046 ); |
|
76807902a2f5
needforspeed: added rpartition implementation
Fredrik Lundh <fredrik@pythonware.com>
parents:
38335
diff
changeset
|
1047 |
|
31199
504943c89193
Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
24753
diff
changeset
|
1048 /* Split a string giving a list of Unicode strings. |
|
504943c89193
Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
24753
diff
changeset
|
1049 |
|
504943c89193
Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
24753
diff
changeset
|
1050 If sep is NULL, splitting will be done at all whitespace |
|
504943c89193
Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
24753
diff
changeset
|
1051 substrings. Otherwise, splits occur at the given separator. |
|
504943c89193
Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
24753
diff
changeset
|
1052 |
|
504943c89193
Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
24753
diff
changeset
|
1053 At most maxsplit splits will be done. But unlike PyUnicode_Split |
|
504943c89193
Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
24753
diff
changeset
|
1054 PyUnicode_RSplit splits from the end of the string. If negative, |
|
504943c89193
Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
24753
diff
changeset
|
1055 no limit is set. |
|
504943c89193
Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
24753
diff
changeset
|
1056 |
|
504943c89193
Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
24753
diff
changeset
|
1057 Separators are not included in the resulting list. |
|
504943c89193
Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
24753
diff
changeset
|
1058 |
|
504943c89193
Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
24753
diff
changeset
|
1059 */ |
|
504943c89193
Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
24753
diff
changeset
|
1060 |
|
504943c89193
Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
24753
diff
changeset
|
1061 PyAPI_FUNC(PyObject*) PyUnicode_RSplit( |
|
504943c89193
Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
24753
diff
changeset
|
1062 PyObject *s, /* String to split */ |
|
504943c89193
Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
24753
diff
changeset
|
1063 PyObject *sep, /* String separator */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
1064 Py_ssize_t maxsplit /* Maxsplit count */ |
|
31199
504943c89193
Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
24753
diff
changeset
|
1065 ); |
|
504943c89193
Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
24753
diff
changeset
|
1066 |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1067 /* Translate a string by applying a character mapping table to it and |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1068 return the resulting Unicode object. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1069 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1070 The mapping table must map Unicode ordinal integers to Unicode |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1071 ordinal integers or None (causing deletion of the character). |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1072 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1073 Mapping tables may be dictionaries or sequences. Unmapped character |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1074 ordinals (ones which cause a LookupError) are left untouched and |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1075 are copied as-is. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1076 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1077 */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1078 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1079 PyAPI_FUNC(PyObject *) PyUnicode_Translate( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1080 PyObject *str, /* String */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1081 PyObject *table, /* Translate table */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1082 const char *errors /* error handling */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1083 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1084 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1085 /* Join a sequence of strings using the given separator and return |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1086 the resulting Unicode string. */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1087 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1088 PyAPI_FUNC(PyObject*) PyUnicode_Join( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1089 PyObject *separator, /* Separator string */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1090 PyObject *seq /* Sequence object */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1091 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1092 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1093 /* Return 1 if substr matches str[start:end] at the given tail end, 0 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1094 otherwise. */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1095 |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
1096 PyAPI_FUNC(Py_ssize_t) PyUnicode_Tailmatch( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1097 PyObject *str, /* String */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1098 PyObject *substr, /* Prefix or Suffix string */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
1099 Py_ssize_t start, /* Start index */ |
|
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
1100 Py_ssize_t end, /* Stop index */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1101 int direction /* Tail end: -1 prefix, +1 suffix */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1102 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1103 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1104 /* Return the first position of substr in str[start:end] using the |
|
23561
c5e8f89fd358
Fix for bug [ 561796 ] string.find causes lazy error
Marc-André Lemburg <mal@egenix.com>
parents:
23225
diff
changeset
|
1105 given search direction or -1 if not found. -2 is returned in case |
|
c5e8f89fd358
Fix for bug [ 561796 ] string.find causes lazy error
Marc-André Lemburg <mal@egenix.com>
parents:
23225
diff
changeset
|
1106 an error occurred and an exception is set. */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1107 |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
1108 PyAPI_FUNC(Py_ssize_t) PyUnicode_Find( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1109 PyObject *str, /* String */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1110 PyObject *substr, /* Substring to find */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
1111 Py_ssize_t start, /* Start index */ |
|
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
1112 Py_ssize_t end, /* Stop index */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1113 int direction /* Find direction: +1 forward, -1 backward */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1114 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1115 |
|
12025
7994d9db7f4d
On 17-Mar-2000, Marc-Andre Lemburg said:
Barry Warsaw <barry@python.org>
parents:
12002
diff
changeset
|
1116 /* Count the number of occurrences of substr in str[start:end]. */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1117 |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
1118 PyAPI_FUNC(Py_ssize_t) PyUnicode_Count( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1119 PyObject *str, /* String */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1120 PyObject *substr, /* Substring to count */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
1121 Py_ssize_t start, /* Start index */ |
|
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
1122 Py_ssize_t end /* Stop index */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1123 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1124 |
|
12025
7994d9db7f4d
On 17-Mar-2000, Marc-Andre Lemburg said:
Barry Warsaw <barry@python.org>
parents:
12002
diff
changeset
|
1125 /* Replace at most maxcount occurrences of substr in str with replstr |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1126 and return the resulting Unicode object. */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1127 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1128 PyAPI_FUNC(PyObject *) PyUnicode_Replace( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1129 PyObject *str, /* String */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1130 PyObject *substr, /* Substring to find */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1131 PyObject *replstr, /* Substring to replace */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35808
diff
changeset
|
1132 Py_ssize_t maxcount /* Max. number of replacements to apply; |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1133 -1 = all */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1134 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1135 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1136 /* Compare two strings and return -1, 0, 1 for less than, equal, |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1137 greater than resp. */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1138 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1139 PyAPI_FUNC(int) PyUnicode_Compare( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1140 PyObject *left, /* Left string */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1141 PyObject *right /* Right string */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1142 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1143 |
|
39487
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
1144 /* Rich compare two strings and return one of the following: |
|
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
1145 |
|
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
1146 - NULL in case an exception was raised |
|
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
1147 - Py_True or Py_False for successfuly comparisons |
|
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
1148 - Py_NotImplemented in case the type combination is unknown |
|
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
1149 |
|
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
1150 Note that Py_EQ and Py_NE comparisons can cause a UnicodeWarning in |
|
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
1151 case the conversion of the arguments to Unicode fails with a |
|
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
1152 UnicodeDecodeError. |
|
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
1153 |
|
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
1154 Possible values for op: |
|
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
1155 |
|
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
1156 Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE |
|
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
1157 |
|
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
1158 */ |
|
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
1159 |
|
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
1160 PyAPI_FUNC(PyObject *) PyUnicode_RichCompare( |
|
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
1161 PyObject *left, /* Left string */ |
|
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
1162 PyObject *right, /* Right string */ |
|
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
1163 int op /* Operation: Py_EQ, Py_NE, Py_GT, etc. */ |
|
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
1164 ); |
|
635b09b1f542
Slightly revised version of patch #1538956:
Marc-André Lemburg <mal@egenix.com>
parents:
38817
diff
changeset
|
1165 |
|
13620
5b727ab37092
Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in either
Thomas Wouters <thomas@python.org>
parents:
13401
diff
changeset
|
1166 /* Apply a argument tuple or dictionary to a format string and return |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1167 the resulting Unicode string. */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1168 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1169 PyAPI_FUNC(PyObject *) PyUnicode_Format( |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1170 PyObject *format, /* Format string */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1171 PyObject *args /* Argument tuple or dictionary */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1172 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1173 |
|
12002
d50fa3670b66
Marc-Andre Lemburg: add declaration for PyUnicode_Contains().
Guido van Rossum <guido@python.org>
parents:
11962
diff
changeset
|
1174 /* Checks whether element is contained in container and return 1/0 |
|
d50fa3670b66
Marc-Andre Lemburg: add declaration for PyUnicode_Contains().
Guido van Rossum <guido@python.org>
parents:
11962
diff
changeset
|
1175 accordingly. |
|
d50fa3670b66
Marc-Andre Lemburg: add declaration for PyUnicode_Contains().
Guido van Rossum <guido@python.org>
parents:
11962
diff
changeset
|
1176 |
|
d50fa3670b66
Marc-Andre Lemburg: add declaration for PyUnicode_Contains().
Guido van Rossum <guido@python.org>
parents:
11962
diff
changeset
|
1177 element has to coerce to an one element Unicode string. -1 is |
|
d50fa3670b66
Marc-Andre Lemburg: add declaration for PyUnicode_Contains().
Guido van Rossum <guido@python.org>
parents:
11962
diff
changeset
|
1178 returned in case of an error. */ |
|
d50fa3670b66
Marc-Andre Lemburg: add declaration for PyUnicode_Contains().
Guido van Rossum <guido@python.org>
parents:
11962
diff
changeset
|
1179 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1180 PyAPI_FUNC(int) PyUnicode_Contains( |
|
12002
d50fa3670b66
Marc-Andre Lemburg: add declaration for PyUnicode_Contains().
Guido van Rossum <guido@python.org>
parents:
11962
diff
changeset
|
1181 PyObject *container, /* Container string */ |
|
d50fa3670b66
Marc-Andre Lemburg: add declaration for PyUnicode_Contains().
Guido van Rossum <guido@python.org>
parents:
11962
diff
changeset
|
1182 PyObject *element /* Element string */ |
|
d50fa3670b66
Marc-Andre Lemburg: add declaration for PyUnicode_Contains().
Guido van Rossum <guido@python.org>
parents:
11962
diff
changeset
|
1183 ); |
|
d50fa3670b66
Marc-Andre Lemburg: add declaration for PyUnicode_Contains().
Guido van Rossum <guido@python.org>
parents:
11962
diff
changeset
|
1184 |
|
23225
e639e34ef901
Apply patch diff.txt from SF feature request
Walter Dörwald <walter@livinglogic.de>
parents:
20554
diff
changeset
|
1185 /* Externally visible for str.strip(unicode) */ |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1186 PyAPI_FUNC(PyObject *) _PyUnicode_XStrip( |
|
23225
e639e34ef901
Apply patch diff.txt from SF feature request
Walter Dörwald <walter@livinglogic.de>
parents:
20554
diff
changeset
|
1187 PyUnicodeObject *self, |
|
e639e34ef901
Apply patch diff.txt from SF feature request
Walter Dörwald <walter@livinglogic.de>
parents:
20554
diff
changeset
|
1188 int striptype, |
|
e639e34ef901
Apply patch diff.txt from SF feature request
Walter Dörwald <walter@livinglogic.de>
parents:
20554
diff
changeset
|
1189 PyObject *sepobj |
|
e639e34ef901
Apply patch diff.txt from SF feature request
Walter Dörwald <walter@livinglogic.de>
parents:
20554
diff
changeset
|
1190 ); |
|
e639e34ef901
Apply patch diff.txt from SF feature request
Walter Dörwald <walter@livinglogic.de>
parents:
20554
diff
changeset
|
1191 |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1192 /* === Characters Type APIs =============================================== */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1193 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1194 /* These should not be used directly. Use the Py_UNICODE_IS* and |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1195 Py_UNICODE_TO* macros instead. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1196 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1197 These APIs are implemented in Objects/unicodectype.c. |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1198 |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1199 */ |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1200 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1201 PyAPI_FUNC(int) _PyUnicode_IsLowercase( |
|
18332
49acc8ac60c2
removed "register const" from scalar arguments to the unicode
Fredrik Lundh <fredrik@pythonware.com>
parents:
18324
diff
changeset
|
1202 Py_UNICODE ch /* Unicode character */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1203 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1204 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1205 PyAPI_FUNC(int) _PyUnicode_IsUppercase( |
|
18332
49acc8ac60c2
removed "register const" from scalar arguments to the unicode
Fredrik Lundh <fredrik@pythonware.com>
parents:
18324
diff
changeset
|
1206 Py_UNICODE ch /* Unicode character */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1207 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1208 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1209 PyAPI_FUNC(int) _PyUnicode_IsTitlecase( |
|
18332
49acc8ac60c2
removed "register const" from scalar arguments to the unicode
Fredrik Lundh <fredrik@pythonware.com>
parents:
18324
diff
changeset
|
1210 Py_UNICODE ch /* Unicode character */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1211 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1212 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1213 PyAPI_FUNC(int) _PyUnicode_IsWhitespace( |
|
35808
c2a98ba371c8
_PyUnicode_IsWhitespace(),
Tim Peters <tim.peters@gmail.com>
parents:
35485
diff
changeset
|
1214 const Py_UNICODE ch /* Unicode character */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1215 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1216 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1217 PyAPI_FUNC(int) _PyUnicode_IsLinebreak( |
|
35808
c2a98ba371c8
_PyUnicode_IsWhitespace(),
Tim Peters <tim.peters@gmail.com>
parents:
35485
diff
changeset
|
1218 const Py_UNICODE ch /* Unicode character */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1219 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1220 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1221 PyAPI_FUNC(Py_UNICODE) _PyUnicode_ToLowercase( |
|
18332
49acc8ac60c2
removed "register const" from scalar arguments to the unicode
Fredrik Lundh <fredrik@pythonware.com>
parents:
18324
diff
changeset
|
1222 Py_UNICODE ch /* Unicode character */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1223 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1224 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1225 PyAPI_FUNC(Py_UNICODE) _PyUnicode_ToUppercase( |
|
18332
49acc8ac60c2
removed "register const" from scalar arguments to the unicode
Fredrik Lundh <fredrik@pythonware.com>
parents:
18324
diff
changeset
|
1226 Py_UNICODE ch /* Unicode character */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1227 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1228 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1229 PyAPI_FUNC(Py_UNICODE) _PyUnicode_ToTitlecase( |
|
18332
49acc8ac60c2
removed "register const" from scalar arguments to the unicode
Fredrik Lundh <fredrik@pythonware.com>
parents:
18324
diff
changeset
|
1230 Py_UNICODE ch /* Unicode character */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1231 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1232 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1233 PyAPI_FUNC(int) _PyUnicode_ToDecimalDigit( |
|
18332
49acc8ac60c2
removed "register const" from scalar arguments to the unicode
Fredrik Lundh <fredrik@pythonware.com>
parents:
18324
diff
changeset
|
1234 Py_UNICODE ch /* Unicode character */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1235 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1236 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1237 PyAPI_FUNC(int) _PyUnicode_ToDigit( |
|
18332
49acc8ac60c2
removed "register const" from scalar arguments to the unicode
Fredrik Lundh <fredrik@pythonware.com>
parents:
18324
diff
changeset
|
1238 Py_UNICODE ch /* Unicode character */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1239 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1240 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1241 PyAPI_FUNC(double) _PyUnicode_ToNumeric( |
|
18332
49acc8ac60c2
removed "register const" from scalar arguments to the unicode
Fredrik Lundh <fredrik@pythonware.com>
parents:
18324
diff
changeset
|
1242 Py_UNICODE ch /* Unicode character */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1243 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1244 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1245 PyAPI_FUNC(int) _PyUnicode_IsDecimalDigit( |
|
18332
49acc8ac60c2
removed "register const" from scalar arguments to the unicode
Fredrik Lundh <fredrik@pythonware.com>
parents:
18324
diff
changeset
|
1246 Py_UNICODE ch /* Unicode character */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1247 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1248 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1249 PyAPI_FUNC(int) _PyUnicode_IsDigit( |
|
18332
49acc8ac60c2
removed "register const" from scalar arguments to the unicode
Fredrik Lundh <fredrik@pythonware.com>
parents:
18324
diff
changeset
|
1250 Py_UNICODE ch /* Unicode character */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1251 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1252 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1253 PyAPI_FUNC(int) _PyUnicode_IsNumeric( |
|
18332
49acc8ac60c2
removed "register const" from scalar arguments to the unicode
Fredrik Lundh <fredrik@pythonware.com>
parents:
18324
diff
changeset
|
1254 Py_UNICODE ch /* Unicode character */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1255 ); |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1256 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24737
diff
changeset
|
1257 PyAPI_FUNC(int) _PyUnicode_IsAlpha( |
|
18332
49acc8ac60c2
removed "register const" from scalar arguments to the unicode
Fredrik Lundh <fredrik@pythonware.com>
parents:
18324
diff
changeset
|
1258 Py_UNICODE ch /* Unicode character */ |
|
13352
d88535ccaee5
Modified the ISALPHA and ISALNUM macros to use the new lookup APIs
Marc-André Lemburg <mal@egenix.com>
parents:
13320
diff
changeset
|
1259 ); |
|
d88535ccaee5
Modified the ISALPHA and ISALNUM macros to use the new lookup APIs
Marc-André Lemburg <mal@egenix.com>
parents:
13320
diff
changeset
|
1260 |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1261 #ifdef __cplusplus |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1262 } |
|
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1263 #endif |
|
19343
7257e87e0720
Patch #445762: Support --disable-unicode
Martin v. Löwis <martin@v.loewis.de>
parents:
19121
diff
changeset
|
1264 #endif /* Py_USING_UNICODE */ |
|
11962
be98e055e39d
Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1265 #endif /* !Py_UNICODEOBJECT_H */ |
