annotate Include/unicodeobject.h @ 72181:c1949bde461e

Minor improvement to extensions in setup.cfg: check parent package
author Éric Araujo <merwok@netwok.org>
date Thu, 01 Sep 2011 07:01:13 +0200
parents 77171f993bf2
children 218e297f72e1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
44999
7c02182e2979 Merged revisions 60284-60349 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44586
diff changeset
4 #include <stdarg.h>
7c02182e2979 Merged revisions 60284-60349 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44586
diff changeset
5
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 /*
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
7
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 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
9 modified by Marc-Andre Lemburg (mal@lemburg.com) according to the
66206
52fe60216e89 Merged revisions 86478 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 65113
diff changeset
10 Unicode Integration Proposal. (See
52fe60216e89 Merged revisions 86478 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 65113
diff changeset
11 http://www.egenix.com/files/python/unicode-proposal.txt).
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
12
13828
254f8b7c4a83 Changing the CNRI copyright notice according to CNRI's instructions.
Guido van Rossum <guido@python.org>
parents: 13661
diff changeset
13 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
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 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
17 --------------------------------------------------------------------
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 * 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
20 * 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
21 *
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 * 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
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 * 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
25 * 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
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 * 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
28 * 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
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 * --------------------------------------------------------------------
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
31 * This Unicode String Type is
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
32 *
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 * 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
34 * Copyright (c) 1999 by Fredrik Lundh
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
35 *
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 * 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
37 * 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
38 * and will comply with the following terms and conditions:
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
39 *
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
40 * 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
41 * 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
42 * 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
43 * 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
44 * 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
45 * 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
46 * 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
47 * permission.
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
48 *
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
49 * 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
50 * 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
51 * 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
52 * 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
53 * 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
54 * 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
55 * 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
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
19980
9ab6af6815af Fix for bug #462737.
Marc-André Lemburg <mal@egenix.com>
parents: 19849
diff changeset
58 #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
59
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
60 /* === 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
61
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
62 /* --- 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
63
44586
a2938c55200c Always define Py_USING_UNICODE, 3rd party software may depend on it. A missing declaration can lead to strange bugs as I had to learn the hard way in the upcoming merge
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
64 /* Python 3.x requires unicode */
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
65 #define Py_USING_UNICODE
44586
a2938c55200c Always define Py_USING_UNICODE, 3rd party software may depend on it. A missing declaration can lead to strange bugs as I had to learn the hard way in the upcoming merge
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
66
18296
22f85c6a6520 Make Unicode work a bit better on Windows...
Fredrik Lundh <fredrik@pythonware.com>
parents: 18292
diff changeset
67 /* 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
68 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
69 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
70
22f85c6a6520 Make Unicode work a bit better on Windows...
Fredrik Lundh <fredrik@pythonware.com>
parents: 18292
diff changeset
71 #ifndef Py_UNICODE_SIZE
22f85c6a6520 Make Unicode work a bit better on Windows...
Fredrik Lundh <fredrik@pythonware.com>
parents: 18292
diff changeset
72 #error Must define Py_UNICODE_SIZE
22f85c6a6520 Make Unicode work a bit better on Windows...
Fredrik Lundh <fredrik@pythonware.com>
parents: 18292
diff changeset
73 #endif
22f85c6a6520 Make Unicode work a bit better on Windows...
Fredrik Lundh <fredrik@pythonware.com>
parents: 18292
diff changeset
74
18324
3ba7a358ce02 use Py_UNICODE_WIDE instead of USE_UCS4_STORAGE and Py_UNICODE_SIZE
Fredrik Lundh <fredrik@pythonware.com>
parents: 18298
diff changeset
75 /* 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
76 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
77
3ba7a358ce02 use Py_UNICODE_WIDE instead of USE_UCS4_STORAGE and Py_UNICODE_SIZE
Fredrik Lundh <fredrik@pythonware.com>
parents: 18298
diff changeset
78 #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
79 #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
80 #endif
18280
0632dcd69ea3 experimental UCS-4 support: added USE_UCS4_STORAGE define to
Fredrik Lundh <fredrik@pythonware.com>
parents: 17887
diff changeset
81
64687
9cdba6864eb6 #9210: remove --with-wctype-functions configure option.
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 64639
diff changeset
82 /* Set these flags if the platform has "wchar.h" and the
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 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
84 /* #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
85 /* #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
86
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
87 /* 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
88 #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
89
18280
0632dcd69ea3 experimental UCS-4 support: added USE_UCS4_STORAGE define to
Fredrik Lundh <fredrik@pythonware.com>
parents: 17887
diff changeset
90 /* 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
91 # 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
92 # 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
93 # 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
94 # endif
ffbb9c918ac0 Support using UCS-4 as the Py_UNICODE type:
Martin v. Löwis <martin@v.loewis.de>
parents: 18280
diff changeset
95
18324
3ba7a358ce02 use Py_UNICODE_WIDE instead of USE_UCS4_STORAGE and Py_UNICODE_SIZE
Fredrik Lundh <fredrik@pythonware.com>
parents: 18298
diff changeset
96 # 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
97 # 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
98 # endif
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
99
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
100 #endif
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
101
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
102 /* If the compiler provides a wchar_t type we try to support it
65007
7c7d1d96e2c3 Issue #9979: Create function PyUnicode_AsWideCharString().
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64687
diff changeset
103 through the interface functions PyUnicode_FromWideChar(),
7c7d1d96e2c3 Issue #9979: Create function PyUnicode_AsWideCharString().
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64687
diff changeset
104 PyUnicode_AsWideChar() and PyUnicode_AsWideCharString(). */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
105
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
106 #ifdef HAVE_USABLE_WCHAR_T
13917
03fa40528d17 Added #fndef's to avoid compiler errors.
Marc-André Lemburg <mal@egenix.com>
parents: 13837
diff changeset
107 # ifndef HAVE_WCHAR_H
03fa40528d17 Added #fndef's to avoid compiler errors.
Marc-André Lemburg <mal@egenix.com>
parents: 13837
diff changeset
108 # define HAVE_WCHAR_H
03fa40528d17 Added #fndef's to avoid compiler errors.
Marc-André Lemburg <mal@egenix.com>
parents: 13837
diff changeset
109 # 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
110 #endif
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
111
71193
13e6d3cb2ecd Issue #9642: Uniformize the tests on the availability of the mbcs codec
Victor Stinner <victor.stinner@haypocalc.com>
parents: 68258
diff changeset
112 #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
13e6d3cb2ecd Issue #9642: Uniformize the tests on the availability of the mbcs codec
Victor Stinner <victor.stinner@haypocalc.com>
parents: 68258
diff changeset
113 # define HAVE_MBCS
13e6d3cb2ecd Issue #9642: Uniformize the tests on the availability of the mbcs codec
Victor Stinner <victor.stinner@haypocalc.com>
parents: 68258
diff changeset
114 #endif
13e6d3cb2ecd Issue #9642: Uniformize the tests on the availability of the mbcs codec
Victor Stinner <victor.stinner@haypocalc.com>
parents: 68258
diff changeset
115
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
116 #ifdef HAVE_WCHAR_H
12074
65f35b73e350 Marc-Andre Lemburg:
Guido van Rossum <guido@python.org>
parents: 12066
diff changeset
117 /* Work around a cosmetic bug in BSDI 4.x wchar.h; thanks to Thomas Wouters */
65f35b73e350 Marc-Andre Lemburg:
Guido van Rossum <guido@python.org>
parents: 12066
diff changeset
118 # ifdef _HAVE_BSDI
65f35b73e350 Marc-Andre Lemburg:
Guido van Rossum <guido@python.org>
parents: 12066
diff changeset
119 # include <time.h>
65f35b73e350 Marc-Andre Lemburg:
Guido van Rossum <guido@python.org>
parents: 12066
diff changeset
120 # endif
19980
9ab6af6815af Fix for bug #462737.
Marc-André Lemburg <mal@egenix.com>
parents: 19849
diff changeset
121 # 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
122 #endif
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
123
18292
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 * 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
126 * 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
127 */
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
128 #if SIZEOF_INT >= 4
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
129 typedef unsigned int Py_UCS4;
18292
ffbb9c918ac0 Support using UCS-4 as the Py_UNICODE type:
Martin v. Löwis <martin@v.loewis.de>
parents: 18280
diff changeset
130 #elif SIZEOF_LONG >= 4
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
131 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
132 #endif
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
133
50660
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
134 /* Py_UNICODE is the native Unicode storage format (code unit) used by
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
135 Python and represents a single Unicode element in the Unicode
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
136 type. */
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
137
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
138 #ifndef Py_LIMITED_API
18292
ffbb9c918ac0 Support using UCS-4 as the Py_UNICODE type:
Martin v. Löwis <martin@v.loewis.de>
parents: 18280
diff changeset
139 typedef PY_UNICODE_TYPE Py_UNICODE;
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
140 #endif
13393
bcb14627b8f4 Bill Tutt: Added Py_UCS4 typedef to hold UCS4 values (these need
Marc-André Lemburg <mal@egenix.com>
parents: 13352
diff changeset
141
18911
55b45b47fc48 As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents: 18887
diff changeset
142 /* --- 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
143
55b45b47fc48 As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents: 18887
diff changeset
144 /* 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
145 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
146 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
147 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
148
55b45b47fc48 As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents: 18887
diff changeset
149 #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
150
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_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
152 # define PyUnicode_AsCharmapString PyUnicodeUCS2_AsCharmapString
47496
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
153 # define PyUnicode_AsDecodedObject PyUnicodeUCS2_AsDecodedObject
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
154 # define PyUnicode_AsDecodedUnicode PyUnicodeUCS2_AsDecodedUnicode
32551
f46d49e2e0f0 Allow string and unicode return types from .encode()/.decode()
Marc-André Lemburg <mal@egenix.com>
parents: 32197
diff changeset
155 # 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
156 # define PyUnicode_AsEncodedString PyUnicodeUCS2_AsEncodedString
47496
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
157 # define PyUnicode_AsEncodedUnicode PyUnicodeUCS2_AsEncodedUnicode
18911
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_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
159 # define PyUnicode_AsRawUnicodeEscapeString PyUnicodeUCS2_AsRawUnicodeEscapeString
42626
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
160 # define PyUnicode_AsUTF32String PyUnicodeUCS2_AsUTF32String
18911
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_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
162 # 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
163 # 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
164 # 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
165 # define PyUnicode_AsWideChar PyUnicodeUCS2_AsWideChar
65007
7c7d1d96e2c3 Issue #9979: Create function PyUnicode_AsWideCharString().
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64687
diff changeset
166 # define PyUnicode_AsWideCharString PyUnicodeUCS2_AsWideCharString
50550
db464426a365 Merged revisions 67972 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49553
diff changeset
167 # define PyUnicode_ClearFreeList PyUnicodeUCS2_ClearFreelist
18911
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_Compare PyUnicodeUCS2_Compare
65627
db5a5080f9b8 Issue #8761: Mangle PyUnicode_CompareWithASCIIString function name for
Victor Stinner <victor.stinner@haypocalc.com>
parents: 65494
diff changeset
169 # define PyUnicode_CompareWithASCIIString PyUnicodeUCS2_CompareWithASCIIString
18911
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_Concat PyUnicodeUCS2_Concat
41769
b29d71d43c80 Add functions PyUnicode_Append() and PyUnicode_AppendAndDel() that mirror
Walter Dörwald <walter@livinglogic.de>
parents: 41768
diff changeset
171 # define PyUnicode_Append PyUnicodeUCS2_Append
b29d71d43c80 Add functions PyUnicode_Append() and PyUnicode_AppendAndDel() that mirror
Walter Dörwald <walter@livinglogic.de>
parents: 41768
diff changeset
172 # define PyUnicode_AppendAndDel PyUnicodeUCS2_AppendAndDel
18911
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_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
174 # 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
175 # 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
176 # 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
177 # 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
178 # define PyUnicode_DecodeLatin1 PyUnicodeUCS2_DecodeLatin1
43569
19319e70fc3e Patch #1272, by Christian Heimes and Alexandre Vassalotti.
Guido van Rossum <guido@python.org>
parents: 42984
diff changeset
179 # define PyUnicode_DecodeFSDefault PyUnicodeUCS2_DecodeFSDefault
43761
658cd34a8c5d Fixed a bug in PyUnicode_DecodeFSDefault. strcmp() returns 0 on success.
Christian Heimes <christian@cheimes.de>
parents: 43569
diff changeset
180 # define PyUnicode_DecodeFSDefaultAndSize PyUnicodeUCS2_DecodeFSDefaultAndSize
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_DecodeRawUnicodeEscape PyUnicodeUCS2_DecodeRawUnicodeEscape
42626
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
182 # define PyUnicode_DecodeUTF32 PyUnicodeUCS2_DecodeUTF32
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
183 # define PyUnicode_DecodeUTF32Stateful PyUnicodeUCS2_DecodeUTF32Stateful
18911
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_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
185 # 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
186 # 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
187 # 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
188 # 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
189 # 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
190 # 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
191 # 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
192 # 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
193 # 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
194 # define PyUnicode_EncodeRawUnicodeEscape PyUnicodeUCS2_EncodeRawUnicodeEscape
42626
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
195 # define PyUnicode_EncodeUTF32 PyUnicodeUCS2_EncodeUTF32
18911
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_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
197 # 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
198 # 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
199 # 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
200 # 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
201 # define PyUnicode_FromEncodedObject PyUnicodeUCS2_FromEncodedObject
50550
db464426a365 Merged revisions 67972 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49553
diff changeset
202 # define PyUnicode_FromFormat PyUnicodeUCS2_FromFormat
db464426a365 Merged revisions 67972 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49553
diff changeset
203 # define PyUnicode_FromFormatV PyUnicodeUCS2_FromFormatV
18911
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_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
205 # define PyUnicode_FromOrdinal PyUnicodeUCS2_FromOrdinal
41619
61acfb831633 Add PyUnicode_FromString(), which create a unicode object from a
Walter Dörwald <walter@livinglogic.de>
parents: 41587
diff changeset
206 # define PyUnicode_FromString PyUnicodeUCS2_FromString
41766
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41619
diff changeset
207 # define PyUnicode_FromStringAndSize PyUnicodeUCS2_FromStringAndSize
50550
db464426a365 Merged revisions 67972 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49553
diff changeset
208 # define PyUnicode_FromUnicode PyUnicodeUCS2_FromUnicode
41768
b592985a953f Add missing #define.
Walter Dörwald <walter@livinglogic.de>
parents: 41766
diff changeset
209 # define PyUnicode_FromWideChar PyUnicodeUCS2_FromWideChar
53767
ac209f132b17 Issue #5915: Implement PEP 383, Non-decodable Bytes in
Martin v. Löwis <martin@v.loewis.de>
parents: 53742
diff changeset
210 # define PyUnicode_FSConverter PyUnicodeUCS2_FSConverter
63963
50c0dbaeaa04 Issue #9542: Create PyUnicode_FSDecoder() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63912
diff changeset
211 # define PyUnicode_FSDecoder PyUnicodeUCS2_FSDecoder
18911
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_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
213 # 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
214 # define PyUnicode_GetSize PyUnicodeUCS2_GetSize
42597
20477cbfd996 Implement PEP 3131. Add isidentifier to str.
Martin v. Löwis <martin@v.loewis.de>
parents: 42595
diff changeset
215 # define PyUnicode_IsIdentifier PyUnicodeUCS2_IsIdentifier
18911
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_Join PyUnicodeUCS2_Join
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 36501
diff changeset
217 # define PyUnicode_Partition PyUnicodeUCS2_Partition
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 36501
diff changeset
218 # define PyUnicode_RPartition PyUnicodeUCS2_RPartition
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 36501
diff changeset
219 # 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
220 # 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
221 # define PyUnicode_Resize PyUnicodeUCS2_Resize
39610
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
222 # 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
223 # 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
224 # 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
225 # 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
226 # 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
227 # 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
228 # 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
229 # 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
230 # define _PyUnicode_Init _PyUnicodeUCS2_Init
64373
1f04b0076fd8 Create PyUnicode_strdup() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64372
diff changeset
231 # define PyUnicode_strdup PyUnicodeUCS2_strdup
18911
55b45b47fc48 As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents: 18887
diff changeset
232
55b45b47fc48 As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents: 18887
diff changeset
233 #else
55b45b47fc48 As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents: 18887
diff changeset
234
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_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
236 # define PyUnicode_AsCharmapString PyUnicodeUCS4_AsCharmapString
47496
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
237 # define PyUnicode_AsDecodedObject PyUnicodeUCS4_AsDecodedObject
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
238 # define PyUnicode_AsDecodedUnicode PyUnicodeUCS4_AsDecodedUnicode
32551
f46d49e2e0f0 Allow string and unicode return types from .encode()/.decode()
Marc-André Lemburg <mal@egenix.com>
parents: 32197
diff changeset
239 # 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
240 # define PyUnicode_AsEncodedString PyUnicodeUCS4_AsEncodedString
47496
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
241 # define PyUnicode_AsEncodedUnicode PyUnicodeUCS4_AsEncodedUnicode
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_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
243 # define PyUnicode_AsRawUnicodeEscapeString PyUnicodeUCS4_AsRawUnicodeEscapeString
42626
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
244 # define PyUnicode_AsUTF32String PyUnicodeUCS4_AsUTF32String
18911
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_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
246 # 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
247 # 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
248 # 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
249 # define PyUnicode_AsWideChar PyUnicodeUCS4_AsWideChar
65007
7c7d1d96e2c3 Issue #9979: Create function PyUnicode_AsWideCharString().
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64687
diff changeset
250 # define PyUnicode_AsWideCharString PyUnicodeUCS4_AsWideCharString
50550
db464426a365 Merged revisions 67972 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49553
diff changeset
251 # define PyUnicode_ClearFreeList PyUnicodeUCS4_ClearFreelist
18911
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_Compare PyUnicodeUCS4_Compare
65627
db5a5080f9b8 Issue #8761: Mangle PyUnicode_CompareWithASCIIString function name for
Victor Stinner <victor.stinner@haypocalc.com>
parents: 65494
diff changeset
253 # define PyUnicode_CompareWithASCIIString PyUnicodeUCS4_CompareWithASCIIString
18911
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_Concat PyUnicodeUCS4_Concat
41769
b29d71d43c80 Add functions PyUnicode_Append() and PyUnicode_AppendAndDel() that mirror
Walter Dörwald <walter@livinglogic.de>
parents: 41768
diff changeset
255 # define PyUnicode_Append PyUnicodeUCS4_Append
b29d71d43c80 Add functions PyUnicode_Append() and PyUnicode_AppendAndDel() that mirror
Walter Dörwald <walter@livinglogic.de>
parents: 41768
diff changeset
256 # define PyUnicode_AppendAndDel PyUnicodeUCS4_AppendAndDel
18911
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_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
258 # 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
259 # 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
260 # 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
261 # 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
262 # define PyUnicode_DecodeLatin1 PyUnicodeUCS4_DecodeLatin1
43569
19319e70fc3e Patch #1272, by Christian Heimes and Alexandre Vassalotti.
Guido van Rossum <guido@python.org>
parents: 42984
diff changeset
263 # define PyUnicode_DecodeFSDefault PyUnicodeUCS4_DecodeFSDefault
43761
658cd34a8c5d Fixed a bug in PyUnicode_DecodeFSDefault. strcmp() returns 0 on success.
Christian Heimes <christian@cheimes.de>
parents: 43569
diff changeset
264 # define PyUnicode_DecodeFSDefaultAndSize PyUnicodeUCS4_DecodeFSDefaultAndSize
18911
55b45b47fc48 As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents: 18887
diff changeset
265 # define PyUnicode_DecodeRawUnicodeEscape PyUnicodeUCS4_DecodeRawUnicodeEscape
42626
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
266 # define PyUnicode_DecodeUTF32 PyUnicodeUCS4_DecodeUTF32
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
267 # define PyUnicode_DecodeUTF32Stateful PyUnicodeUCS4_DecodeUTF32Stateful
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_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
269 # 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
270 # 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
271 # 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
272 # 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
273 # 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
274 # 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
275 # 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
276 # 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
277 # 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
278 # define PyUnicode_EncodeRawUnicodeEscape PyUnicodeUCS4_EncodeRawUnicodeEscape
42626
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
279 # define PyUnicode_EncodeUTF32 PyUnicodeUCS4_EncodeUTF32
18911
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_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
281 # 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
282 # 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
283 # 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
284 # 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
285 # define PyUnicode_FromEncodedObject PyUnicodeUCS4_FromEncodedObject
50550
db464426a365 Merged revisions 67972 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49553
diff changeset
286 # define PyUnicode_FromFormat PyUnicodeUCS4_FromFormat
db464426a365 Merged revisions 67972 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49553
diff changeset
287 # define PyUnicode_FromFormatV PyUnicodeUCS4_FromFormatV
18911
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_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
289 # define PyUnicode_FromOrdinal PyUnicodeUCS4_FromOrdinal
41619
61acfb831633 Add PyUnicode_FromString(), which create a unicode object from a
Walter Dörwald <walter@livinglogic.de>
parents: 41587
diff changeset
290 # define PyUnicode_FromString PyUnicodeUCS4_FromString
41766
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41619
diff changeset
291 # define PyUnicode_FromStringAndSize PyUnicodeUCS4_FromStringAndSize
50550
db464426a365 Merged revisions 67972 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49553
diff changeset
292 # define PyUnicode_FromUnicode PyUnicodeUCS4_FromUnicode
18911
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_FromWideChar PyUnicodeUCS4_FromWideChar
53767
ac209f132b17 Issue #5915: Implement PEP 383, Non-decodable Bytes in
Martin v. Löwis <martin@v.loewis.de>
parents: 53742
diff changeset
294 # define PyUnicode_FSConverter PyUnicodeUCS4_FSConverter
63963
50c0dbaeaa04 Issue #9542: Create PyUnicode_FSDecoder() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63912
diff changeset
295 # define PyUnicode_FSDecoder PyUnicodeUCS4_FSDecoder
18911
55b45b47fc48 As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents: 18887
diff changeset
296 # 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
297 # 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
298 # define PyUnicode_GetSize PyUnicodeUCS4_GetSize
42597
20477cbfd996 Implement PEP 3131. Add isidentifier to str.
Martin v. Löwis <martin@v.loewis.de>
parents: 42595
diff changeset
299 # define PyUnicode_IsIdentifier PyUnicodeUCS4_IsIdentifier
18911
55b45b47fc48 As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents: 18887
diff changeset
300 # define PyUnicode_Join PyUnicodeUCS4_Join
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 36501
diff changeset
301 # define PyUnicode_Partition PyUnicodeUCS4_Partition
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 36501
diff changeset
302 # define PyUnicode_RPartition PyUnicodeUCS4_RPartition
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 36501
diff changeset
303 # 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
304 # 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
305 # define PyUnicode_Resize PyUnicodeUCS4_Resize
39610
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
306 # 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
307 # 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
308 # 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
309 # 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
310 # 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
311 # 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
312 # 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
313 # 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
314 # define _PyUnicode_Init _PyUnicodeUCS4_Init
64373
1f04b0076fd8 Create PyUnicode_strdup() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64372
diff changeset
315 # define PyUnicode_strdup PyUnicodeUCS4_strdup
18911
55b45b47fc48 As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents: 18887
diff changeset
316
55b45b47fc48 As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents: 18887
diff changeset
317 #endif
55b45b47fc48 As discussed on python-dev: this patch adds name mangling to
Marc-André Lemburg <mal@egenix.com>
parents: 18887
diff changeset
318
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
319 /* --- 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
320
50660
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
321 /* Since splitting on whitespace is an important use case, and
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
322 whitespace in most situations is solely ASCII whitespace, we
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
323 optimize for the common case by using a quick look-up table
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
324 _Py_ascii_whitespace (see below) with an inlined check.
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
325
45056
c8fca9b5cd3c Merged revisions 60408-60440 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44999
diff changeset
326 */
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
327 #ifndef Py_LIMITED_API
45056
c8fca9b5cd3c Merged revisions 60408-60440 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44999
diff changeset
328 #define Py_UNICODE_ISSPACE(ch) \
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
329 ((ch) < 128U ? _Py_ascii_whitespace[(ch)] : _PyUnicode_IsWhitespace(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
330
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
331 #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
332 #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
333 #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
334 #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
335
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_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
337 #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
338 #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
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_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
341 #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
342 #define Py_UNICODE_ISNUMERIC(ch) _PyUnicode_IsNumeric(ch)
47611
da47e7e135ae #2630: Implement PEP 3138.
Georg Brandl <georg@python.org>
parents: 47496
diff changeset
343 #define Py_UNICODE_ISPRINTABLE(ch) _PyUnicode_IsPrintable(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
344
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_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
346 #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
347 #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
348
13352
d88535ccaee5 Modified the ISALPHA and ISALNUM macros to use the new lookup APIs
Marc-André Lemburg <mal@egenix.com>
parents: 13320
diff changeset
349 #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
350
13320
67a04816ea50 Added new Py_UNICODE_ISALPHA() and Py_UNICODE_ISALNUM() macros
Marc-André Lemburg <mal@egenix.com>
parents: 12956
diff changeset
351 #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
352 (Py_UNICODE_ISALPHA(ch) || \
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
353 Py_UNICODE_ISDECIMAL(ch) || \
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
354 Py_UNICODE_ISDIGIT(ch) || \
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
355 Py_UNICODE_ISNUMERIC(ch))
13320
67a04816ea50 Added new Py_UNICODE_ISALPHA() and Py_UNICODE_ISALNUM() macros
Marc-André Lemburg <mal@egenix.com>
parents: 12956
diff changeset
356
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
357 #define Py_UNICODE_COPY(target, source, length) \
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
358 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
359
50660
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
360 #define Py_UNICODE_FILL(target, value, length) \
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
361 do {Py_ssize_t i_; Py_UNICODE *t_ = (target); Py_UNICODE v_ = (value);\
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
362 for (i_ = 0; i_ < (length); i_++) t_[i_] = v_;\
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 36501
diff changeset
363 } 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
364
72036
77171f993bf2 #10542: Add 4 macros to work with surrogates: Py_UNICODE_IS_SURROGATE, Py_UNICODE_IS_HIGH_SURROGATE, Py_UNICODE_IS_LOW_SURROGATE, Py_UNICODE_JOIN_SURROGATES.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 71193
diff changeset
365 /* macros to work with surrogates */
77171f993bf2 #10542: Add 4 macros to work with surrogates: Py_UNICODE_IS_SURROGATE, Py_UNICODE_IS_HIGH_SURROGATE, Py_UNICODE_IS_LOW_SURROGATE, Py_UNICODE_JOIN_SURROGATES.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 71193
diff changeset
366 #define Py_UNICODE_IS_SURROGATE(ch) (0xD800 <= ch && ch <= 0xDFFF)
77171f993bf2 #10542: Add 4 macros to work with surrogates: Py_UNICODE_IS_SURROGATE, Py_UNICODE_IS_HIGH_SURROGATE, Py_UNICODE_IS_LOW_SURROGATE, Py_UNICODE_JOIN_SURROGATES.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 71193
diff changeset
367 #define Py_UNICODE_IS_HIGH_SURROGATE(ch) (0xD800 <= ch && ch <= 0xDBFF)
77171f993bf2 #10542: Add 4 macros to work with surrogates: Py_UNICODE_IS_SURROGATE, Py_UNICODE_IS_HIGH_SURROGATE, Py_UNICODE_IS_LOW_SURROGATE, Py_UNICODE_JOIN_SURROGATES.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 71193
diff changeset
368 #define Py_UNICODE_IS_LOW_SURROGATE(ch) (0xDC00 <= ch && ch <= 0xDFFF)
77171f993bf2 #10542: Add 4 macros to work with surrogates: Py_UNICODE_IS_SURROGATE, Py_UNICODE_IS_HIGH_SURROGATE, Py_UNICODE_IS_LOW_SURROGATE, Py_UNICODE_JOIN_SURROGATES.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 71193
diff changeset
369 /* Join two surrogate characters and return a single Py_UCS4 value. */
77171f993bf2 #10542: Add 4 macros to work with surrogates: Py_UNICODE_IS_SURROGATE, Py_UNICODE_IS_HIGH_SURROGATE, Py_UNICODE_IS_LOW_SURROGATE, Py_UNICODE_JOIN_SURROGATES.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 71193
diff changeset
370 #define Py_UNICODE_JOIN_SURROGATES(high, low) \
77171f993bf2 #10542: Add 4 macros to work with surrogates: Py_UNICODE_IS_SURROGATE, Py_UNICODE_IS_HIGH_SURROGATE, Py_UNICODE_IS_LOW_SURROGATE, Py_UNICODE_JOIN_SURROGATES.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 71193
diff changeset
371 (((((Py_UCS4)(high) & 0x03FF) << 10) | \
77171f993bf2 #10542: Add 4 macros to work with surrogates: Py_UNICODE_IS_SURROGATE, Py_UNICODE_IS_HIGH_SURROGATE, Py_UNICODE_IS_LOW_SURROGATE, Py_UNICODE_JOIN_SURROGATES.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 71193
diff changeset
372 ((Py_UCS4)(low) & 0x03FF)) + 0x10000)
77171f993bf2 #10542: Add 4 macros to work with surrogates: Py_UNICODE_IS_SURROGATE, Py_UNICODE_IS_HIGH_SURROGATE, Py_UNICODE_IS_LOW_SURROGATE, Py_UNICODE_JOIN_SURROGATES.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 71193
diff changeset
373
66206
52fe60216e89 Merged revisions 86478 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 65113
diff changeset
374 /* Check if substring matches at given offset. The offset must be
52fe60216e89 Merged revisions 86478 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 65113
diff changeset
375 valid, and the substring must not be empty. */
50660
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
376
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 36501
diff changeset
377 #define Py_UNICODE_MATCH(string, offset, substring) \
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 36501
diff changeset
378 ((*((string)->str + (offset)) == *((substring)->str)) && \
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 36501
diff changeset
379 ((*((string)->str + (offset) + (substring)->length-1) == *((substring)->str + (substring)->length-1))) && \
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 36501
diff changeset
380 !memcmp((string)->str + (offset), (substring)->str, (substring)->length*sizeof(Py_UNICODE)))
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
381 #endif /* Py_LIMITED_API */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
382
12025
7994d9db7f4d On 17-Mar-2000, Marc-Andre Lemburg said:
Barry Warsaw <barry@python.org>
parents: 12002
diff changeset
383 #ifdef __cplusplus
7994d9db7f4d On 17-Mar-2000, Marc-Andre Lemburg said:
Barry Warsaw <barry@python.org>
parents: 12002
diff changeset
384 extern "C" {
7994d9db7f4d On 17-Mar-2000, Marc-Andre Lemburg said:
Barry Warsaw <barry@python.org>
parents: 12002
diff changeset
385 #endif
7994d9db7f4d On 17-Mar-2000, Marc-Andre Lemburg said:
Barry Warsaw <barry@python.org>
parents: 12002
diff changeset
386
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
387 /* --- 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
388
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
389 #ifndef Py_LIMITED_API
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
390 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
391 PyObject_HEAD
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
392 Py_ssize_t length; /* Length of raw Unicode data in buffer */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
393 Py_UNICODE *str; /* Raw Unicode buffer */
65494
e8969fb822fc make hashes always the size of pointers; introduce Py_hash_t #9778
Benjamin Peterson <benjamin@python.org>
parents: 65348
diff changeset
394 Py_hash_t hash; /* Hash value; -1 if not set */
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
395 int state; /* != 0 if interned. In this case the two
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
396 * references from the dictionary to this object
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
397 * are *not* counted in ob_refcnt. */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
398 PyObject *defenc; /* (Default) Encoded version as Python
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
399 string, or NULL; this is used for
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
400 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
401 } PyUnicodeObject;
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
402 #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
403
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
404 PyAPI_DATA(PyTypeObject) PyUnicode_Type;
44061
0cc552ab76bd Added all PyTypeObjects to the appropriate header files.
Christian Heimes <christian@cheimes.de>
parents: 43933
diff changeset
405 PyAPI_DATA(PyTypeObject) PyUnicodeIter_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
406
41876
dcb43f40390b Add interning of unicode strings by copying the functionality from
Walter Dörwald <walter@livinglogic.de>
parents: 41769
diff changeset
407 #define SSTATE_NOT_INTERNED 0
dcb43f40390b Add interning of unicode strings by copying the functionality from
Walter Dörwald <walter@livinglogic.de>
parents: 41769
diff changeset
408 #define SSTATE_INTERNED_MORTAL 1
dcb43f40390b Add interning of unicode strings by copying the functionality from
Walter Dörwald <walter@livinglogic.de>
parents: 41769
diff changeset
409 #define SSTATE_INTERNED_IMMORTAL 2
dcb43f40390b Add interning of unicode strings by copying the functionality from
Walter Dörwald <walter@livinglogic.de>
parents: 41769
diff changeset
410
40909
f2f0b41f270d Merged revisions 53875-53911 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39610
diff changeset
411 #define PyUnicode_Check(op) \
44351
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 44061
diff changeset
412 PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS)
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 44061
diff changeset
413 #define PyUnicode_CheckExact(op) (Py_TYPE(op) == &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
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 /* Fast access macros */
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
416 #ifndef Py_LIMITED_API
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
417 #define PyUnicode_GET_SIZE(op) \
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
418 (assert(PyUnicode_Check(op)),(((PyUnicodeObject *)(op))->length))
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
419 #define PyUnicode_GET_DATA_SIZE(op) \
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
420 (assert(PyUnicode_Check(op)),(((PyUnicodeObject *)(op))->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
421 #define PyUnicode_AS_UNICODE(op) \
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
422 (assert(PyUnicode_Check(op)),(((PyUnicodeObject *)(op))->str))
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
423 #define PyUnicode_AS_DATA(op) \
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
424 (assert(PyUnicode_Check(op)),((const char *)((PyUnicodeObject *)(op))->str))
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
425 #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
426
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
427 /* --- Constants ---------------------------------------------------------- */
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 /* 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
430 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
431 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
432 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
433
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
434 #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
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 /* === 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
437
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
438 /* --- 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
439
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
440 /* Create a Unicode Object from the Py_UNICODE buffer u of the given
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
441 size.
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
442
b44ba7c01217 This patch originated from an idea by Martin v. Loewis who submitted a
Marc-André Lemburg <mal@egenix.com>
parents: 13917
diff changeset
443 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
444 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
445 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
446 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
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 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
449
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
450 #ifndef Py_LIMITED_API
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
451 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
452 const Py_UNICODE *u, /* Unicode buffer */
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 35808
diff changeset
453 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
454 );
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
455 #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
456
65113
c9879b3402e4 Merged revisions 82262,82269,82434,82480-82481,82484-82485,82487-82488,82594,82599,82615 via svnmerge from
Georg Brandl <georg@python.org>
parents: 61577
diff changeset
457 /* Similar to PyUnicode_FromUnicode(), but u points to UTF-8 encoded bytes */
41766
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41619
diff changeset
458 PyAPI_FUNC(PyObject*) PyUnicode_FromStringAndSize(
67152
f61196453c78 Issue #9738: Ooops, fix typos in my previous commit (r87506)
Victor Stinner <victor.stinner@haypocalc.com>
parents: 67150
diff changeset
459 const char *u, /* UTF-8 encoded string */
67150
4bb7f7b151fe Issue #9738: document encodings of unicode functions
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66751
diff changeset
460 Py_ssize_t size /* size of buffer */
41766
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41619
diff changeset
461 );
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41619
diff changeset
462
41619
61acfb831633 Add PyUnicode_FromString(), which create a unicode object from a
Walter Dörwald <walter@livinglogic.de>
parents: 41587
diff changeset
463 /* Similar to PyUnicode_FromUnicode(), but u points to null-terminated
65113
c9879b3402e4 Merged revisions 82262,82269,82434,82480-82481,82484-82485,82487-82488,82594,82599,82615 via svnmerge from
Georg Brandl <georg@python.org>
parents: 61577
diff changeset
464 UTF-8 encoded bytes */
41619
61acfb831633 Add PyUnicode_FromString(), which create a unicode object from a
Walter Dörwald <walter@livinglogic.de>
parents: 41587
diff changeset
465 PyAPI_FUNC(PyObject*) PyUnicode_FromString(
67150
4bb7f7b151fe Issue #9738: document encodings of unicode functions
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66751
diff changeset
466 const char *u /* UTF-8 encoded string */
41619
61acfb831633 Add PyUnicode_FromString(), which create a unicode object from a
Walter Dörwald <walter@livinglogic.de>
parents: 41587
diff changeset
467 );
61acfb831633 Add PyUnicode_FromString(), which create a unicode object from a
Walter Dörwald <walter@livinglogic.de>
parents: 41587
diff changeset
468
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
469 /* 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
470 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
471
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
472 #ifndef Py_LIMITED_API
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
473 PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
474 PyObject *unicode /* Unicode object */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
475 );
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
476 #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
477
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
478 /* 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
479
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 35808
diff changeset
480 PyAPI_FUNC(Py_ssize_t) PyUnicode_GetSize(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
481 PyObject *unicode /* Unicode object */
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
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
484 #ifndef Py_LIMITED_API
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
485 /* 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
486 PyAPI_FUNC(Py_UNICODE) PyUnicode_GetMax(void);
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
487 #endif
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
488
12326
9488e4fdafe4 Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents: 12248
diff changeset
489 /* 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
490
9488e4fdafe4 Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents: 12248
diff changeset
491 *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
492 returned on success.
9488e4fdafe4 Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents: 12248
diff changeset
493
9488e4fdafe4 Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents: 12248
diff changeset
494 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
495 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
496 an error is returned.
9488e4fdafe4 Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents: 12248
diff changeset
497
9488e4fdafe4 Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents: 12248
diff changeset
498 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
499 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
500
9488e4fdafe4 Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents: 12248
diff changeset
501 */
9488e4fdafe4 Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents: 12248
diff changeset
502
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
503 PyAPI_FUNC(int) PyUnicode_Resize(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
504 PyObject **unicode, /* Pointer to the Unicode object */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
505 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
506 );
9488e4fdafe4 Marc-Andre Lemburg: New exported API PyUnicode_Resize().
Guido van Rossum <guido@python.org>
parents: 12248
diff changeset
507
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 /* 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
509 *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
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 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
512
65113
c9879b3402e4 Merged revisions 82262,82269,82434,82480-82481,82484-82485,82487-82488,82594,82599,82615 via svnmerge from
Georg Brandl <georg@python.org>
parents: 61577
diff changeset
513 1. bytes, bytearray and other char buffer compatible objects are decoded
66206
52fe60216e89 Merged revisions 86478 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 65113
diff changeset
514 under the assumptions that they contain data using the UTF-8
52fe60216e89 Merged revisions 86478 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 65113
diff changeset
515 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
516
20554
0336ee5b46d4 SF patch #470578: Fixes to synchronize unicode() and str()
Guido van Rossum <guido@python.org>
parents: 19998
diff changeset
517 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
518 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
519
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
520 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
521 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
522
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
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
525 PyAPI_FUNC(PyObject*) PyUnicode_FromEncodedObject(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
526 register PyObject *obj, /* Object */
13401
8f1a2deeb9b0 Added new API PyUnicode_FromEncodedObject() which supports decoding
Marc-André Lemburg <mal@egenix.com>
parents: 13393
diff changeset
527 const char *encoding, /* encoding */
8f1a2deeb9b0 Added new API PyUnicode_FromEncodedObject() which supports decoding
Marc-André Lemburg <mal@egenix.com>
parents: 13393
diff changeset
528 const char *errors /* error handling */
8f1a2deeb9b0 Added new API PyUnicode_FromEncodedObject() which supports decoding
Marc-André Lemburg <mal@egenix.com>
parents: 13393
diff changeset
529 );
8f1a2deeb9b0 Added new API PyUnicode_FromEncodedObject() which supports decoding
Marc-André Lemburg <mal@egenix.com>
parents: 13393
diff changeset
530
20554
0336ee5b46d4 SF patch #470578: Fixes to synchronize unicode() and str()
Guido van Rossum <guido@python.org>
parents: 19998
diff changeset
531 /* 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
532 *incremented* refcount.
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
533
20554
0336ee5b46d4 SF patch #470578: Fixes to synchronize unicode() and str()
Guido van Rossum <guido@python.org>
parents: 19998
diff changeset
534 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
535 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
536 PyUnicode_FromEncodedObject(obj, NULL, "strict") which results in
65113
c9879b3402e4 Merged revisions 82262,82269,82434,82480-82481,82484-82485,82487-82488,82594,82599,82615 via svnmerge from
Georg Brandl <georg@python.org>
parents: 61577
diff changeset
537 using UTF-8 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
538
8f1a2deeb9b0 Added new API PyUnicode_FromEncodedObject() which supports decoding
Marc-André Lemburg <mal@egenix.com>
parents: 13393
diff changeset
539 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
540 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
541
8f1a2deeb9b0 Added new API PyUnicode_FromEncodedObject() which supports decoding
Marc-André Lemburg <mal@egenix.com>
parents: 13393
diff changeset
542 */
8f1a2deeb9b0 Added new API PyUnicode_FromEncodedObject() which supports decoding
Marc-André Lemburg <mal@egenix.com>
parents: 13393
diff changeset
543
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
544 PyAPI_FUNC(PyObject*) PyUnicode_FromObject(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
545 register PyObject *obj /* Object */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
546 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
547
64639
1cfad55de5bd Issue #9738: PyUnicode_FromFormat() and PyErr_Format() raise an error on
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64397
diff changeset
548 PyAPI_FUNC(PyObject *) PyUnicode_FromFormatV(
1cfad55de5bd Issue #9738: PyUnicode_FromFormat() and PyErr_Format() raise an error on
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64397
diff changeset
549 const char *format, /* ASCII-encoded string */
1cfad55de5bd Issue #9738: PyUnicode_FromFormat() and PyErr_Format() raise an error on
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64397
diff changeset
550 va_list vargs
1cfad55de5bd Issue #9738: PyUnicode_FromFormat() and PyErr_Format() raise an error on
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64397
diff changeset
551 );
1cfad55de5bd Issue #9738: PyUnicode_FromFormat() and PyErr_Format() raise an error on
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64397
diff changeset
552 PyAPI_FUNC(PyObject *) PyUnicode_FromFormat(
1cfad55de5bd Issue #9738: PyUnicode_FromFormat() and PyErr_Format() raise an error on
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64397
diff changeset
553 const char *format, /* ASCII-encoded string */
1cfad55de5bd Issue #9738: PyUnicode_FromFormat() and PyErr_Format() raise an error on
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64397
diff changeset
554 ...
1cfad55de5bd Issue #9738: PyUnicode_FromFormat() and PyErr_Format() raise an error on
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64397
diff changeset
555 );
41766
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41619
diff changeset
556
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
557 #ifndef Py_LIMITED_API
47393
0da27fdf0192 Refactor and clean up str.format() code (and helpers) in advance of optimizations.
Eric Smith <eric@trueblade.com>
parents: 46909
diff changeset
558 /* Format the object based on the format_spec, as defined in PEP 3101
0da27fdf0192 Refactor and clean up str.format() code (and helpers) in advance of optimizations.
Eric Smith <eric@trueblade.com>
parents: 46909
diff changeset
559 (Advanced String Formatting). */
0da27fdf0192 Refactor and clean up str.format() code (and helpers) in advance of optimizations.
Eric Smith <eric@trueblade.com>
parents: 46909
diff changeset
560 PyAPI_FUNC(PyObject *) _PyUnicode_FormatAdvanced(PyObject *obj,
0da27fdf0192 Refactor and clean up str.format() code (and helpers) in advance of optimizations.
Eric Smith <eric@trueblade.com>
parents: 46909
diff changeset
561 Py_UNICODE *format_spec,
0da27fdf0192 Refactor and clean up str.format() code (and helpers) in advance of optimizations.
Eric Smith <eric@trueblade.com>
parents: 46909
diff changeset
562 Py_ssize_t format_spec_len);
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
563 #endif
47393
0da27fdf0192 Refactor and clean up str.format() code (and helpers) in advance of optimizations.
Eric Smith <eric@trueblade.com>
parents: 46909
diff changeset
564
41876
dcb43f40390b Add interning of unicode strings by copying the functionality from
Walter Dörwald <walter@livinglogic.de>
parents: 41769
diff changeset
565 PyAPI_FUNC(void) PyUnicode_InternInPlace(PyObject **);
dcb43f40390b Add interning of unicode strings by copying the functionality from
Walter Dörwald <walter@livinglogic.de>
parents: 41769
diff changeset
566 PyAPI_FUNC(void) PyUnicode_InternImmortal(PyObject **);
67150
4bb7f7b151fe Issue #9738: document encodings of unicode functions
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66751
diff changeset
567 PyAPI_FUNC(PyObject *) PyUnicode_InternFromString(
4bb7f7b151fe Issue #9738: document encodings of unicode functions
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66751
diff changeset
568 const char *u /* UTF-8 encoded string */
4bb7f7b151fe Issue #9738: document encodings of unicode functions
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66751
diff changeset
569 );
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
570 #ifndef Py_LIMITED_API
41876
dcb43f40390b Add interning of unicode strings by copying the functionality from
Walter Dörwald <walter@livinglogic.de>
parents: 41769
diff changeset
571 PyAPI_FUNC(void) _Py_ReleaseInternedUnicodeStrings(void);
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
572 #endif
41876
dcb43f40390b Add interning of unicode strings by copying the functionality from
Walter Dörwald <walter@livinglogic.de>
parents: 41769
diff changeset
573
dcb43f40390b Add interning of unicode strings by copying the functionality from
Walter Dörwald <walter@livinglogic.de>
parents: 41769
diff changeset
574 /* Use only if you know it's a string */
dcb43f40390b Add interning of unicode strings by copying the functionality from
Walter Dörwald <walter@livinglogic.de>
parents: 41769
diff changeset
575 #define PyUnicode_CHECK_INTERNED(op) (((PyUnicodeObject *)(op))->state)
dcb43f40390b Add interning of unicode strings by copying the functionality from
Walter Dörwald <walter@livinglogic.de>
parents: 41769
diff changeset
576
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
577 /* --- 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
578
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
579 #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
580
65113
c9879b3402e4 Merged revisions 82262,82269,82434,82480-82481,82484-82485,82487-82488,82594,82599,82615 via svnmerge from
Georg Brandl <georg@python.org>
parents: 61577
diff changeset
581 /* Create a Unicode Object from the wchar_t buffer w of the given
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
582 size.
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
583
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
584 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
585
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
586 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
587 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
588 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
589 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
590
34016
264e45baacd5 Correct the handling of 0-termination of PyUnicode_AsWideChar()
Marc-André Lemburg <mal@egenix.com>
parents: 33864
diff changeset
591 /* 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
592 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
593
34016
264e45baacd5 Correct the handling of 0-termination of PyUnicode_AsWideChar()
Marc-André Lemburg <mal@egenix.com>
parents: 33864
diff changeset
594 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
595 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
596 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
597 the application.
264e45baacd5 Correct the handling of 0-termination of PyUnicode_AsWideChar()
Marc-André Lemburg <mal@egenix.com>
parents: 33864
diff changeset
598
264e45baacd5 Correct the handling of 0-termination of PyUnicode_AsWideChar()
Marc-André Lemburg <mal@egenix.com>
parents: 33864
diff changeset
599 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
600 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
601 error. */
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
602
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 35808
diff changeset
603 PyAPI_FUNC(Py_ssize_t) PyUnicode_AsWideChar(
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
604 PyObject *unicode, /* Unicode object */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
605 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
606 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
607 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
608
65007
7c7d1d96e2c3 Issue #9979: Create function PyUnicode_AsWideCharString().
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64687
diff changeset
609 /* Convert the Unicode object to a wide character string. The output string
7c7d1d96e2c3 Issue #9979: Create function PyUnicode_AsWideCharString().
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64687
diff changeset
610 always ends with a nul character. If size is not NULL, write the number of
7c7d1d96e2c3 Issue #9979: Create function PyUnicode_AsWideCharString().
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64687
diff changeset
611 wide characters (including the nul character) into *size.
7c7d1d96e2c3 Issue #9979: Create function PyUnicode_AsWideCharString().
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64687
diff changeset
612
7c7d1d96e2c3 Issue #9979: Create function PyUnicode_AsWideCharString().
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64687
diff changeset
613 Returns a buffer allocated by PyMem_Alloc() (use PyMem_Free() to free it)
7c7d1d96e2c3 Issue #9979: Create function PyUnicode_AsWideCharString().
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64687
diff changeset
614 on success. On error, returns NULL, *size is undefined and raises a
7c7d1d96e2c3 Issue #9979: Create function PyUnicode_AsWideCharString().
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64687
diff changeset
615 MemoryError. */
7c7d1d96e2c3 Issue #9979: Create function PyUnicode_AsWideCharString().
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64687
diff changeset
616
7c7d1d96e2c3 Issue #9979: Create function PyUnicode_AsWideCharString().
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64687
diff changeset
617 PyAPI_FUNC(wchar_t*) PyUnicode_AsWideCharString(
65157
e3ae5b00ba15 PyUnicode_AsWideCharString() takes a PyObject*, not a PyUnicodeObject*
Victor Stinner <victor.stinner@haypocalc.com>
parents: 65007
diff changeset
618 PyObject *unicode, /* Unicode object */
65007
7c7d1d96e2c3 Issue #9979: Create function PyUnicode_AsWideCharString().
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64687
diff changeset
619 Py_ssize_t *size /* number of characters of the result */
7c7d1d96e2c3 Issue #9979: Create function PyUnicode_AsWideCharString().
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64687
diff changeset
620 );
7c7d1d96e2c3 Issue #9979: Create function PyUnicode_AsWideCharString().
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64687
diff changeset
621
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
622 #endif
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
623
24737
eaa87632b1e8 Add C API PyUnicode_FromOrdinal() which exposes unichr() at C level.
Marc-André Lemburg <mal@egenix.com>
parents: 23561
diff changeset
624 /* --- Unicode ordinals --------------------------------------------------- */
eaa87632b1e8 Add C API PyUnicode_FromOrdinal() which exposes unichr() at C level.
Marc-André Lemburg <mal@egenix.com>
parents: 23561
diff changeset
625
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
626 /* Create a Unicode Object from the given Unicode code point ordinal.
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
627
24737
eaa87632b1e8 Add C API PyUnicode_FromOrdinal() which exposes unichr() at C level.
Marc-André Lemburg <mal@egenix.com>
parents: 23561
diff changeset
628 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
629 (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
630 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
631
eaa87632b1e8 Add C API PyUnicode_FromOrdinal() which exposes unichr() at C level.
Marc-André Lemburg <mal@egenix.com>
parents: 23561
diff changeset
632 */
eaa87632b1e8 Add C API PyUnicode_FromOrdinal() which exposes unichr() at C level.
Marc-André Lemburg <mal@egenix.com>
parents: 23561
diff changeset
633
24753
27ae978bee58 Add name mangling for new PyUnicode_FromOrdinal() and fix declaration
Marc-André Lemburg <mal@egenix.com>
parents: 24752
diff changeset
634 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
635
50660
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
636 /* --- Free-list management ----------------------------------------------- */
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
637
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
638 /* Clear the free list used by the Unicode implementation.
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
639
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
640 This can be used to release memory used for objects on the free
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
641 list back to the Python memory allocator.
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
642
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
643 */
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
644
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
645 PyAPI_FUNC(int) PyUnicode_ClearFreeList(void);
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
646
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
647 /* === Builtin Codecs =====================================================
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
648
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
649 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
650 parameters encoding and errors have the same semantics as the ones
66206
52fe60216e89 Merged revisions 86478 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 65113
diff changeset
651 of the builtin str() API.
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
652
65113
c9879b3402e4 Merged revisions 82262,82269,82434,82480-82481,82484-82485,82487-82488,82594,82599,82615 via svnmerge from
Georg Brandl <georg@python.org>
parents: 61577
diff changeset
653 Setting encoding to NULL causes the default encoding (UTF-8) 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
654
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
655 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
656 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
657 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
658 raised).
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
659
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
660 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
661 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
662
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
663 */
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
664
12643
06ff966f69d5 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 12372
diff changeset
665 /* --- Manage the default encoding ---------------------------------------- */
06ff966f69d5 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 12372
diff changeset
666
18887
9b291ca6546c Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 18332
diff changeset
667 /* Return a Python string holding the default encoded value of the
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
668 Unicode object.
18887
9b291ca6546c Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 18332
diff changeset
669
66206
52fe60216e89 Merged revisions 86478 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 65113
diff changeset
670 Same as PyUnicode_AsUTF8String() except
52fe60216e89 Merged revisions 86478 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 65113
diff changeset
671 the resulting string is cached in the Unicode object for subsequent
18887
9b291ca6546c Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 18332
diff changeset
672 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
673 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
674 the Unicode object itself.
9b291ca6546c Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 18332
diff changeset
675
9b291ca6546c Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 18332
diff changeset
676 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
677
9b291ca6546c Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 18332
diff changeset
678 *** 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
679
9b291ca6546c Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 18332
diff changeset
680 */
9b291ca6546c Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 18332
diff changeset
681
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
682 #ifndef Py_LIMITED_API
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
683 PyAPI_FUNC(PyObject *) _PyUnicode_AsDefaultEncodedString(
68207
c7a936362281 Remove useless argument of _PyUnicode_AsDefaultEncodedString()
Victor Stinner <victor.stinner@haypocalc.com>
parents: 67152
diff changeset
684 PyObject *unicode);
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
685 #endif
18887
9b291ca6546c Add _PyUnicode_AsDefaultEncodedString to unicodeobject.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 18332
diff changeset
686
66206
52fe60216e89 Merged revisions 86478 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 65113
diff changeset
687 /* Returns a pointer to the default encoding (UTF-8) of the
46598
0154df250ef6 Cleanup the Unicode header documentation and formatting a bit.
Marc-André Lemburg <mal@egenix.com>
parents: 45371
diff changeset
688 Unicode object unicode and the size of the encoded representation
0154df250ef6 Cleanup the Unicode header documentation and formatting a bit.
Marc-André Lemburg <mal@egenix.com>
parents: 45371
diff changeset
689 in bytes stored in *size.
43761
658cd34a8c5d Fixed a bug in PyUnicode_DecodeFSDefault. strcmp() returns 0 on success.
Christian Heimes <christian@cheimes.de>
parents: 43569
diff changeset
690
46598
0154df250ef6 Cleanup the Unicode header documentation and formatting a bit.
Marc-André Lemburg <mal@egenix.com>
parents: 45371
diff changeset
691 In case of an error, no *size is set.
42984
3a56e73ae919 Add PyUnicode_AsStringAndSize(), which is like PyUnicode_AsString() but
Guido van Rossum <guido@python.org>
parents: 42896
diff changeset
692
48660
85b67fb5672b Rename PyUnicode_AsString -> _PyUnicode_AsString and
Marc-André Lemburg <mal@egenix.com>
parents: 48358
diff changeset
693 *** This API is for interpreter INTERNAL USE ONLY and will likely
66206
52fe60216e89 Merged revisions 86478 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 65113
diff changeset
694 *** be removed or changed in the future.
48660
85b67fb5672b Rename PyUnicode_AsString -> _PyUnicode_AsString and
Marc-André Lemburg <mal@egenix.com>
parents: 48358
diff changeset
695
85b67fb5672b Rename PyUnicode_AsString -> _PyUnicode_AsString and
Marc-André Lemburg <mal@egenix.com>
parents: 48358
diff changeset
696 *** If you need to access the Unicode object as UTF-8 bytes string,
85b67fb5672b Rename PyUnicode_AsString -> _PyUnicode_AsString and
Marc-André Lemburg <mal@egenix.com>
parents: 48358
diff changeset
697 *** please use PyUnicode_AsUTF8String() instead.
85b67fb5672b Rename PyUnicode_AsString -> _PyUnicode_AsString and
Marc-André Lemburg <mal@egenix.com>
parents: 48358
diff changeset
698
42013
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41876
diff changeset
699 */
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41876
diff changeset
700
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
701 #ifndef Py_LIMITED_API
48660
85b67fb5672b Rename PyUnicode_AsString -> _PyUnicode_AsString and
Marc-André Lemburg <mal@egenix.com>
parents: 48358
diff changeset
702 PyAPI_FUNC(char *) _PyUnicode_AsStringAndSize(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
703 PyObject *unicode,
46598
0154df250ef6 Cleanup the Unicode header documentation and formatting a bit.
Marc-André Lemburg <mal@egenix.com>
parents: 45371
diff changeset
704 Py_ssize_t *size);
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
705 #endif
42984
3a56e73ae919 Add PyUnicode_AsStringAndSize(), which is like PyUnicode_AsString() but
Guido van Rossum <guido@python.org>
parents: 42896
diff changeset
706
66206
52fe60216e89 Merged revisions 86478 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 65113
diff changeset
707 /* Returns a pointer to the default encoding (UTF-8) of the
46598
0154df250ef6 Cleanup the Unicode header documentation and formatting a bit.
Marc-André Lemburg <mal@egenix.com>
parents: 45371
diff changeset
708 Unicode object unicode.
42984
3a56e73ae919 Add PyUnicode_AsStringAndSize(), which is like PyUnicode_AsString() but
Guido van Rossum <guido@python.org>
parents: 42896
diff changeset
709
46598
0154df250ef6 Cleanup the Unicode header documentation and formatting a bit.
Marc-André Lemburg <mal@egenix.com>
parents: 45371
diff changeset
710 Use of this API is DEPRECATED since no size information can be
48660
85b67fb5672b Rename PyUnicode_AsString -> _PyUnicode_AsString and
Marc-André Lemburg <mal@egenix.com>
parents: 48358
diff changeset
711 extracted from the returned data.
85b67fb5672b Rename PyUnicode_AsString -> _PyUnicode_AsString and
Marc-André Lemburg <mal@egenix.com>
parents: 48358
diff changeset
712
85b67fb5672b Rename PyUnicode_AsString -> _PyUnicode_AsString and
Marc-André Lemburg <mal@egenix.com>
parents: 48358
diff changeset
713 *** This API is for interpreter INTERNAL USE ONLY and will likely
85b67fb5672b Rename PyUnicode_AsString -> _PyUnicode_AsString and
Marc-André Lemburg <mal@egenix.com>
parents: 48358
diff changeset
714 *** be removed or changed for Python 3.1.
85b67fb5672b Rename PyUnicode_AsString -> _PyUnicode_AsString and
Marc-André Lemburg <mal@egenix.com>
parents: 48358
diff changeset
715
85b67fb5672b Rename PyUnicode_AsString -> _PyUnicode_AsString and
Marc-André Lemburg <mal@egenix.com>
parents: 48358
diff changeset
716 *** If you need to access the Unicode object as UTF-8 bytes string,
85b67fb5672b Rename PyUnicode_AsString -> _PyUnicode_AsString and
Marc-André Lemburg <mal@egenix.com>
parents: 48358
diff changeset
717 *** please use PyUnicode_AsUTF8String() instead.
42984
3a56e73ae919 Add PyUnicode_AsStringAndSize(), which is like PyUnicode_AsString() but
Guido van Rossum <guido@python.org>
parents: 42896
diff changeset
718
46598
0154df250ef6 Cleanup the Unicode header documentation and formatting a bit.
Marc-André Lemburg <mal@egenix.com>
parents: 45371
diff changeset
719 */
0154df250ef6 Cleanup the Unicode header documentation and formatting a bit.
Marc-André Lemburg <mal@egenix.com>
parents: 45371
diff changeset
720
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
721 #ifndef Py_LIMITED_API
48660
85b67fb5672b Rename PyUnicode_AsString -> _PyUnicode_AsString and
Marc-André Lemburg <mal@egenix.com>
parents: 48358
diff changeset
722 PyAPI_FUNC(char *) _PyUnicode_AsString(PyObject *unicode);
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
723 #endif
46598
0154df250ef6 Cleanup the Unicode header documentation and formatting a bit.
Marc-André Lemburg <mal@egenix.com>
parents: 45371
diff changeset
724
66206
52fe60216e89 Merged revisions 86478 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 65113
diff changeset
725 /* Returns "utf-8". */
12643
06ff966f69d5 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 12372
diff changeset
726
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
727 PyAPI_FUNC(const char*) PyUnicode_GetDefaultEncoding(void);
12643
06ff966f69d5 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 12372
diff changeset
728
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 /* --- 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
730
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
731 /* 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
732 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
733
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
734 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
735 const char *s, /* encoded string */
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 35808
diff changeset
736 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
737 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
738 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
739 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
740
47496
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
741 /* Decode a Unicode object unicode and return the result as Python
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
742 object. */
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
743
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
744 PyAPI_FUNC(PyObject*) PyUnicode_AsDecodedObject(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
745 PyObject *unicode, /* Unicode object */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
746 const char *encoding, /* encoding */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
747 const char *errors /* error handling */
47496
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
748 );
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
749
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
750 /* Decode a Unicode object unicode and return the result as Unicode
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
751 object. */
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
752
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
753 PyAPI_FUNC(PyObject*) PyUnicode_AsDecodedUnicode(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
754 PyObject *unicode, /* Unicode object */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
755 const char *encoding, /* encoding */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
756 const char *errors /* error handling */
47496
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
757 );
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
758
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
759 /* Encodes a Py_UNICODE buffer of the given size and returns a
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
760 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
761
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
762 #ifndef Py_LIMITED_API
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
763 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
764 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
765 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
766 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
767 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
768 );
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
769 #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
770
32551
f46d49e2e0f0 Allow string and unicode return types from .encode()/.decode()
Marc-André Lemburg <mal@egenix.com>
parents: 32197
diff changeset
771 /* 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
772 object. */
f46d49e2e0f0 Allow string and unicode return types from .encode()/.decode()
Marc-André Lemburg <mal@egenix.com>
parents: 32197
diff changeset
773
f46d49e2e0f0 Allow string and unicode return types from .encode()/.decode()
Marc-André Lemburg <mal@egenix.com>
parents: 32197
diff changeset
774 PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedObject(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
775 PyObject *unicode, /* Unicode object */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
776 const char *encoding, /* encoding */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
777 const char *errors /* error handling */
32551
f46d49e2e0f0 Allow string and unicode return types from .encode()/.decode()
Marc-André Lemburg <mal@egenix.com>
parents: 32197
diff changeset
778 );
f46d49e2e0f0 Allow string and unicode return types from .encode()/.decode()
Marc-André Lemburg <mal@egenix.com>
parents: 32197
diff changeset
779
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
780 /* 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
781 object. */
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_AsEncodedString(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
784 PyObject *unicode, /* Unicode object */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
785 const char *encoding, /* encoding */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
786 const char *errors /* error handling */
11962
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
47496
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
789 /* Encodes a Unicode object and returns the result as Unicode
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
790 object. */
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
791
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
792 PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedUnicode(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
793 PyObject *unicode, /* Unicode object */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
794 const char *encoding, /* encoding */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
795 const char *errors /* error handling */
47496
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
796 );
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
797
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
798 /* Build an encoding map. */
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 47463
diff changeset
799
38673
a19c20c5e5c7 Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents: 38669
diff changeset
800 PyAPI_FUNC(PyObject*) PyUnicode_BuildEncodingMap(
a19c20c5e5c7 Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents: 38669
diff changeset
801 PyObject* string /* 256 character map */
a19c20c5e5c7 Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents: 38669
diff changeset
802 );
a19c20c5e5c7 Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents: 38669
diff changeset
803
19998
8a0c97453df4 Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents: 19980
diff changeset
804 /* --- UTF-7 Codecs ------------------------------------------------------- */
8a0c97453df4 Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents: 19980
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_DecodeUTF7(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
807 const char *string, /* UTF-7 encoded string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
808 Py_ssize_t length, /* size of string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
809 const char *errors /* error handling */
19998
8a0c97453df4 Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents: 19980
diff changeset
810 );
8a0c97453df4 Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents: 19980
diff changeset
811
43933
9c4bf18e5d30 Merged revisions 59056-59076 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 43761
diff changeset
812 PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF7Stateful(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
813 const char *string, /* UTF-7 encoded string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
814 Py_ssize_t length, /* size of string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
815 const char *errors, /* error handling */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
816 Py_ssize_t *consumed /* bytes consumed */
43933
9c4bf18e5d30 Merged revisions 59056-59076 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 43761
diff changeset
817 );
9c4bf18e5d30 Merged revisions 59056-59076 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 43761
diff changeset
818
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
819 #ifndef Py_LIMITED_API
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
820 PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF7(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
821 const Py_UNICODE *data, /* Unicode char buffer */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
822 Py_ssize_t length, /* number of Py_UNICODE chars to encode */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
823 int base64SetO, /* Encode RFC2152 Set O characters in base64 */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
824 int base64WhiteSpace, /* Encode whitespace (sp, ht, nl, cr) in base64 */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
825 const char *errors /* error handling */
19998
8a0c97453df4 Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents: 19980
diff changeset
826 );
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
827 #endif
19998
8a0c97453df4 Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents: 19980
diff changeset
828
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
829 /* --- 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
830
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
831 PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF8(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
832 const char *string, /* UTF-8 encoded string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
833 Py_ssize_t length, /* size of string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
834 const char *errors /* error handling */
11962
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
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
837 PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF8Stateful(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
838 const char *string, /* UTF-8 encoded string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
839 Py_ssize_t length, /* size of string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
840 const char *errors, /* error handling */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
841 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
842 );
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
843
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
844 PyAPI_FUNC(PyObject*) PyUnicode_AsUTF8String(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
845 PyObject *unicode /* Unicode object */
11962
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
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
848 #ifndef Py_LIMITED_API
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
849 PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF8(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
850 const Py_UNICODE *data, /* Unicode char buffer */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
851 Py_ssize_t length, /* number of Py_UNICODE chars to encode */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
852 const char *errors /* error handling */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
853 );
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
854 #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
855
42626
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
856 /* --- UTF-32 Codecs ------------------------------------------------------ */
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
857
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
858 /* Decodes length bytes from a UTF-32 encoded buffer string and returns
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
859 the corresponding Unicode object.
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
860
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
861 errors (if non-NULL) defines the error handling. It defaults
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
862 to "strict".
42626
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
863
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
864 If byteorder is non-NULL, the decoder starts decoding using the
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
865 given byte order:
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
866
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
867 *byteorder == -1: little endian
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
868 *byteorder == 0: native order
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
869 *byteorder == 1: big endian
42626
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
870
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
871 In native mode, the first four bytes of the stream are checked for a
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
872 BOM mark. If found, the BOM mark is analysed, the byte order
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
873 adjusted and the BOM skipped. In the other modes, no BOM mark
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
874 interpretation is done. After completion, *byteorder is set to the
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
875 current byte order at the end of input data.
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
876
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
877 If byteorder is NULL, the codec starts in native order mode.
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
878
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
879 */
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
880
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
881 PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF32(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
882 const char *string, /* UTF-32 encoded string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
883 Py_ssize_t length, /* size of string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
884 const char *errors, /* error handling */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
885 int *byteorder /* pointer to byteorder to use
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
886 0=native;-1=LE,1=BE; updated on
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
887 exit */
42626
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
888 );
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
889
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
890 PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF32Stateful(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
891 const char *string, /* UTF-32 encoded string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
892 Py_ssize_t length, /* size of string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
893 const char *errors, /* error handling */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
894 int *byteorder, /* pointer to byteorder to use
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
895 0=native;-1=LE,1=BE; updated on
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
896 exit */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
897 Py_ssize_t *consumed /* bytes consumed */
42626
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
898 );
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
899
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
900 /* Returns a Python string using the UTF-32 encoding in native byte
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
901 order. The string always starts with a BOM mark. */
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
902
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
903 PyAPI_FUNC(PyObject*) PyUnicode_AsUTF32String(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
904 PyObject *unicode /* Unicode object */
42626
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
905 );
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
906
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
907 /* Returns a Python string object holding the UTF-32 encoded value of
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
908 the Unicode data.
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
909
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
910 If byteorder is not 0, output is written according to the following
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
911 byte order:
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
912
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
913 byteorder == -1: little endian
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
914 byteorder == 0: native byte order (writes a BOM mark)
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
915 byteorder == 1: big endian
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
916
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
917 If byteorder is 0, the output string will always start with the
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
918 Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
919 prepended.
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
920
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
921 */
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
922
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
923 #ifndef Py_LIMITED_API
42626
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
924 PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF32(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
925 const Py_UNICODE *data, /* Unicode char buffer */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
926 Py_ssize_t length, /* number of Py_UNICODE chars to encode */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
927 const char *errors, /* error handling */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
928 int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */
42626
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
929 );
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
930 #endif
42626
f1a2d51f1cab Apply SF patch #1775604: This adds three new codecs (utf-32, utf-32-le and
Walter Dörwald <walter@livinglogic.de>
parents: 42597
diff changeset
931
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
932 /* --- 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
933
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
934 /* 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
935 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
936
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
937 errors (if non-NULL) defines the error handling. It defaults
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
938 to "strict".
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
939
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
940 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
941 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
942
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
943 *byteorder == -1: little endian
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
944 *byteorder == 0: native order
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
945 *byteorder == 1: big endian
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
946
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
947 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
948 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
949 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
950 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
951 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
952
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
953 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
954
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
955 */
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
956
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
957 PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF16(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
958 const char *string, /* UTF-16 encoded string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
959 Py_ssize_t length, /* size of string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
960 const char *errors, /* error handling */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
961 int *byteorder /* pointer to byteorder to use
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
962 0=native;-1=LE,1=BE; updated on
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
963 exit */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
964 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
965
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
966 PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF16Stateful(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
967 const char *string, /* UTF-16 encoded string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
968 Py_ssize_t length, /* size of string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
969 const char *errors, /* error handling */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
970 int *byteorder, /* pointer to byteorder to use
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
971 0=native;-1=LE,1=BE; updated on
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
972 exit */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
973 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
974 );
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
975
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
976 /* 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
977 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
978
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
979 PyAPI_FUNC(PyObject*) PyUnicode_AsUTF16String(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
980 PyObject *unicode /* Unicode object */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
981 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
982
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
983 /* 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
984 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
985
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
986 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
987 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
988
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
989 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
990 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
991 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
992
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
993 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
994 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
995 prepended.
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
996
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
997 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
998 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
999 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
1000
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1001 */
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1002
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1003 #ifndef Py_LIMITED_API
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1004 PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF16(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1005 const Py_UNICODE *data, /* Unicode char buffer */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1006 Py_ssize_t length, /* number of Py_UNICODE chars to encode */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1007 const char *errors, /* error handling */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1008 int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1009 );
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1010 #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
1011
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1012 /* --- 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
1013
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1014 PyAPI_FUNC(PyObject*) PyUnicode_DecodeUnicodeEscape(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1015 const char *string, /* Unicode-Escape encoded string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1016 Py_ssize_t length, /* size of string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1017 const char *errors /* error handling */
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 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1019
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1020 PyAPI_FUNC(PyObject*) PyUnicode_AsUnicodeEscapeString(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1021 PyObject *unicode /* Unicode object */
11962
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
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1024 #ifndef Py_LIMITED_API
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1025 PyAPI_FUNC(PyObject*) PyUnicode_EncodeUnicodeEscape(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1026 const Py_UNICODE *data, /* Unicode char buffer */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1027 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
1028 );
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1029 #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
1030
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1031 /* --- 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
1032
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1033 PyAPI_FUNC(PyObject*) PyUnicode_DecodeRawUnicodeEscape(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1034 const char *string, /* Raw-Unicode-Escape encoded string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1035 Py_ssize_t length, /* size of string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1036 const char *errors /* error handling */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1037 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1038
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1039 PyAPI_FUNC(PyObject*) PyUnicode_AsRawUnicodeEscapeString(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1040 PyObject *unicode /* Unicode object */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1041 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1042
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1043 #ifndef Py_LIMITED_API
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1044 PyAPI_FUNC(PyObject*) PyUnicode_EncodeRawUnicodeEscape(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1045 const Py_UNICODE *data, /* Unicode char buffer */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1046 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
1047 );
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1048 #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
1049
35485
6b8c55877755 Backport checkin:
Walter Dörwald <walter@livinglogic.de>
parents: 34016
diff changeset
1050 /* --- Unicode Internal Codec ---------------------------------------------
6b8c55877755 Backport checkin:
Walter Dörwald <walter@livinglogic.de>
parents: 34016
diff changeset
1051
6b8c55877755 Backport checkin:
Walter Dörwald <walter@livinglogic.de>
parents: 34016
diff changeset
1052 Only for internal use in _codecsmodule.c */
6b8c55877755 Backport checkin:
Walter Dörwald <walter@livinglogic.de>
parents: 34016
diff changeset
1053
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1054 #ifndef Py_LIMITED_API
35485
6b8c55877755 Backport checkin:
Walter Dörwald <walter@livinglogic.de>
parents: 34016
diff changeset
1055 PyObject *_PyUnicode_DecodeUnicodeInternal(
6b8c55877755 Backport checkin:
Walter Dörwald <walter@livinglogic.de>
parents: 34016
diff changeset
1056 const char *string,
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 35808
diff changeset
1057 Py_ssize_t length,
35485
6b8c55877755 Backport checkin:
Walter Dörwald <walter@livinglogic.de>
parents: 34016
diff changeset
1058 const char *errors
6b8c55877755 Backport checkin:
Walter Dörwald <walter@livinglogic.de>
parents: 34016
diff changeset
1059 );
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1060 #endif
35485
6b8c55877755 Backport checkin:
Walter Dörwald <walter@livinglogic.de>
parents: 34016
diff changeset
1061
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1062 /* --- Latin-1 Codecs -----------------------------------------------------
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1063
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1064 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
1065
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1066 */
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1067
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1068 PyAPI_FUNC(PyObject*) PyUnicode_DecodeLatin1(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1069 const char *string, /* Latin-1 encoded string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1070 Py_ssize_t length, /* size of string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1071 const char *errors /* error handling */
11962
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
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1074 PyAPI_FUNC(PyObject*) PyUnicode_AsLatin1String(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1075 PyObject *unicode /* Unicode object */
11962
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
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1078 #ifndef Py_LIMITED_API
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1079 PyAPI_FUNC(PyObject*) PyUnicode_EncodeLatin1(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1080 const Py_UNICODE *data, /* Unicode char buffer */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1081 Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1082 const char *errors /* error handling */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1083 );
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1084 #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
1085
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1086 /* --- ASCII Codecs -------------------------------------------------------
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1087
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1088 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
1089
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1090 */
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1091
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1092 PyAPI_FUNC(PyObject*) PyUnicode_DecodeASCII(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1093 const char *string, /* ASCII encoded string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1094 Py_ssize_t length, /* size of string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1095 const char *errors /* error handling */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1096 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1097
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1098 PyAPI_FUNC(PyObject*) PyUnicode_AsASCIIString(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1099 PyObject *unicode /* Unicode object */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1100 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1101
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1102 #ifndef Py_LIMITED_API
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1103 PyAPI_FUNC(PyObject*) PyUnicode_EncodeASCII(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1104 const Py_UNICODE *data, /* Unicode char buffer */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1105 Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1106 const char *errors /* error handling */
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 );
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1108 #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
1109
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1110 /* --- Character Map Codecs -----------------------------------------------
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1111
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1112 This codec uses mappings to encode and decode characters.
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
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1114 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
1115 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
1116 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
1117 error).
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1118
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1119 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
1120 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
1121 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
1122 error).
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 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
1125 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
1126 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
1127 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
1128 points.
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1129
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1130 */
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1131
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1132 PyAPI_FUNC(PyObject*) PyUnicode_DecodeCharmap(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1133 const char *string, /* Encoded string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1134 Py_ssize_t length, /* size of string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1135 PyObject *mapping, /* character mapping
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1136 (char ordinal -> unicode ordinal) */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1137 const char *errors /* error handling */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1138 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1139
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1140 PyAPI_FUNC(PyObject*) PyUnicode_AsCharmapString(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1141 PyObject *unicode, /* Unicode object */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1142 PyObject *mapping /* character mapping
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1143 (unicode ordinal -> char ordinal) */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1144 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1145
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1146 #ifndef Py_LIMITED_API
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1147 PyAPI_FUNC(PyObject*) PyUnicode_EncodeCharmap(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1148 const Py_UNICODE *data, /* Unicode char buffer */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1149 Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1150 PyObject *mapping, /* character mapping
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1151 (unicode ordinal -> char ordinal) */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1152 const char *errors /* error handling */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1153 );
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1154 #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
1155
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1156 /* 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
1157 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
1158 object.
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1159
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1160 The mapping table must map Unicode ordinal integers to Unicode
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1161 ordinal integers or None (causing deletion of the 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
1162
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1163 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
1164 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
1165 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
1166
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1167 */
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1168
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1169 #ifndef Py_LIMITED_API
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1170 PyAPI_FUNC(PyObject *) PyUnicode_TranslateCharmap(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1171 const Py_UNICODE *data, /* Unicode char buffer */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1172 Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1173 PyObject *table, /* Translate table */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1174 const char *errors /* error handling */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1175 );
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1176 #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
1177
71193
13e6d3cb2ecd Issue #9642: Uniformize the tests on the availability of the mbcs codec
Victor Stinner <victor.stinner@haypocalc.com>
parents: 68258
diff changeset
1178 #ifdef HAVE_MBCS
12074
65f35b73e350 Marc-Andre Lemburg:
Guido van Rossum <guido@python.org>
parents: 12066
diff changeset
1179
12066
86cffe50fb17 Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents: 12025
diff changeset
1180 /* --- MBCS codecs for Windows -------------------------------------------- */
12074
65f35b73e350 Marc-Andre Lemburg:
Guido van Rossum <guido@python.org>
parents: 12066
diff changeset
1181
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1182 PyAPI_FUNC(PyObject*) PyUnicode_DecodeMBCS(
12066
86cffe50fb17 Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents: 12025
diff changeset
1183 const char *string, /* MBCS encoded string */
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 35808
diff changeset
1184 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
1185 const char *errors /* error handling */
86cffe50fb17 Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents: 12025
diff changeset
1186 );
86cffe50fb17 Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents: 12025
diff changeset
1187
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38673
diff changeset
1188 PyAPI_FUNC(PyObject*) PyUnicode_DecodeMBCSStateful(
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38673
diff changeset
1189 const char *string, /* MBCS encoded string */
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38673
diff changeset
1190 Py_ssize_t length, /* size of string */
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38673
diff changeset
1191 const char *errors, /* error handling */
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38673
diff changeset
1192 Py_ssize_t *consumed /* bytes consumed */
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38673
diff changeset
1193 );
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38673
diff changeset
1194
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1195 PyAPI_FUNC(PyObject*) PyUnicode_AsMBCSString(
12066
86cffe50fb17 Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents: 12025
diff changeset
1196 PyObject *unicode /* Unicode object */
86cffe50fb17 Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents: 12025
diff changeset
1197 );
86cffe50fb17 Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents: 12025
diff changeset
1198
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1199 #ifndef Py_LIMITED_API
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1200 PyAPI_FUNC(PyObject*) PyUnicode_EncodeMBCS(
12066
86cffe50fb17 Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents: 12025
diff changeset
1201 const Py_UNICODE *data, /* Unicode char buffer */
42490
b56a8d822f21 Whitespace normalization.
Neal Norwitz <nnorwitz@gmail.com>
parents: 42334
diff changeset
1202 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
1203 const char *errors /* error handling */
86cffe50fb17 Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents: 12025
diff changeset
1204 );
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1205 #endif
12066
86cffe50fb17 Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents: 12025
diff changeset
1206
71193
13e6d3cb2ecd Issue #9642: Uniformize the tests on the availability of the mbcs codec
Victor Stinner <victor.stinner@haypocalc.com>
parents: 68258
diff changeset
1207 #endif /* HAVE_MBCS */
12066
86cffe50fb17 Prototypes added for MBCS codecs. (Win32 only.)
Guido van Rossum <guido@python.org>
parents: 12025
diff changeset
1208
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
1209 /* --- 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
1210
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
1211 /* 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
1212 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
1213
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
1214 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
1215 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
1216
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
1217 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
1218 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
1219 \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
1220 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
1221
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
1222 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
1223
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
1224 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
1225 "ignore": ignore the wrong characters (these are not copied to the
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1226 output buffer)
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
1227 "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
1228
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
1229 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
1230
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
1231 */
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
1232
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1233 #ifndef Py_LIMITED_API
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1234 PyAPI_FUNC(int) PyUnicode_EncodeDecimal(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1235 Py_UNICODE *s, /* Unicode buffer */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1236 Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1237 char *output, /* Output buffer; must have size >= length */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1238 const char *errors /* error handling */
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
1239 );
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1240 #endif
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
1241
66673
7b6af56ee74d Issue #10557: Fixed error messages from float() and other numeric
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 66664
diff changeset
1242 /* Transforms code points that have decimal digit property to the
7b6af56ee74d Issue #10557: Fixed error messages from float() and other numeric
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 66664
diff changeset
1243 corresponding ASCII digit code points.
7b6af56ee74d Issue #10557: Fixed error messages from float() and other numeric
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 66664
diff changeset
1244
7b6af56ee74d Issue #10557: Fixed error messages from float() and other numeric
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 66664
diff changeset
1245 Returns a new Unicode string on success, NULL on failure.
7b6af56ee74d Issue #10557: Fixed error messages from float() and other numeric
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 66664
diff changeset
1246 */
7b6af56ee74d Issue #10557: Fixed error messages from float() and other numeric
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 66664
diff changeset
1247
66751
902db4722594 Take PyUnicode_TransformDecimalToASCII out of the limited API.
Georg Brandl <georg@python.org>
parents: 66673
diff changeset
1248 #ifndef Py_LIMITED_API
66673
7b6af56ee74d Issue #10557: Fixed error messages from float() and other numeric
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 66664
diff changeset
1249 PyAPI_FUNC(PyObject*) PyUnicode_TransformDecimalToASCII(
7b6af56ee74d Issue #10557: Fixed error messages from float() and other numeric
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 66664
diff changeset
1250 Py_UNICODE *s, /* Unicode buffer */
7b6af56ee74d Issue #10557: Fixed error messages from float() and other numeric
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 66664
diff changeset
1251 Py_ssize_t length /* Number of Py_UNICODE chars to transform */
7b6af56ee74d Issue #10557: Fixed error messages from float() and other numeric
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 66664
diff changeset
1252 );
66751
902db4722594 Take PyUnicode_TransformDecimalToASCII out of the limited API.
Georg Brandl <georg@python.org>
parents: 66673
diff changeset
1253 #endif
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
1254
53767
ac209f132b17 Issue #5915: Implement PEP 383, Non-decodable Bytes in
Martin v. Löwis <martin@v.loewis.de>
parents: 53742
diff changeset
1255 /* --- File system encoding ---------------------------------------------- */
ac209f132b17 Issue #5915: Implement PEP 383, Non-decodable Bytes in
Martin v. Löwis <martin@v.loewis.de>
parents: 53742
diff changeset
1256
63963
50c0dbaeaa04 Issue #9542: Create PyUnicode_FSDecoder() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63912
diff changeset
1257 /* ParseTuple converter: encode str objects to bytes using
50c0dbaeaa04 Issue #9542: Create PyUnicode_FSDecoder() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63912
diff changeset
1258 PyUnicode_EncodeFSDefault(); bytes objects are output as-is. */
53767
ac209f132b17 Issue #5915: Implement PEP 383, Non-decodable Bytes in
Martin v. Löwis <martin@v.loewis.de>
parents: 53742
diff changeset
1259
ac209f132b17 Issue #5915: Implement PEP 383, Non-decodable Bytes in
Martin v. Löwis <martin@v.loewis.de>
parents: 53742
diff changeset
1260 PyAPI_FUNC(int) PyUnicode_FSConverter(PyObject*, void*);
ac209f132b17 Issue #5915: Implement PEP 383, Non-decodable Bytes in
Martin v. Löwis <martin@v.loewis.de>
parents: 53742
diff changeset
1261
63963
50c0dbaeaa04 Issue #9542: Create PyUnicode_FSDecoder() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63912
diff changeset
1262 /* ParseTuple converter: decode bytes objects to unicode using
50c0dbaeaa04 Issue #9542: Create PyUnicode_FSDecoder() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63912
diff changeset
1263 PyUnicode_DecodeFSDefaultAndSize(); str objects are output as-is. */
50c0dbaeaa04 Issue #9542: Create PyUnicode_FSDecoder() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63912
diff changeset
1264
50c0dbaeaa04 Issue #9542: Create PyUnicode_FSDecoder() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63912
diff changeset
1265 PyAPI_FUNC(int) PyUnicode_FSDecoder(PyObject*, void*);
50c0dbaeaa04 Issue #9542: Create PyUnicode_FSDecoder() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63912
diff changeset
1266
61577
2b0af69aef97 Merged revisions 81168 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 61467
diff changeset
1267 /* Decode a null-terminated string using Py_FileSystemDefaultEncoding
2b0af69aef97 Merged revisions 81168 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 61467
diff changeset
1268 and the "surrogateescape" error handler.
53767
ac209f132b17 Issue #5915: Implement PEP 383, Non-decodable Bytes in
Martin v. Löwis <martin@v.loewis.de>
parents: 53742
diff changeset
1269
65348
453fd8182c2f Use locale encoding if Py_FileSystemDefaultEncoding is not set
Victor Stinner <victor.stinner@haypocalc.com>
parents: 65157
diff changeset
1270 If Py_FileSystemDefaultEncoding is not set, fall back to the locale
453fd8182c2f Use locale encoding if Py_FileSystemDefaultEncoding is not set
Victor Stinner <victor.stinner@haypocalc.com>
parents: 65157
diff changeset
1271 encoding.
53767
ac209f132b17 Issue #5915: Implement PEP 383, Non-decodable Bytes in
Martin v. Löwis <martin@v.loewis.de>
parents: 53742
diff changeset
1272
61601
042e6a396a86 rephrase
Benjamin Peterson <benjamin@python.org>
parents: 61597
diff changeset
1273 Use PyUnicode_DecodeFSDefaultAndSize() if the string length is known.
53767
ac209f132b17 Issue #5915: Implement PEP 383, Non-decodable Bytes in
Martin v. Löwis <martin@v.loewis.de>
parents: 53742
diff changeset
1274 */
ac209f132b17 Issue #5915: Implement PEP 383, Non-decodable Bytes in
Martin v. Löwis <martin@v.loewis.de>
parents: 53742
diff changeset
1275
ac209f132b17 Issue #5915: Implement PEP 383, Non-decodable Bytes in
Martin v. Löwis <martin@v.loewis.de>
parents: 53742
diff changeset
1276 PyAPI_FUNC(PyObject*) PyUnicode_DecodeFSDefault(
ac209f132b17 Issue #5915: Implement PEP 383, Non-decodable Bytes in
Martin v. Löwis <martin@v.loewis.de>
parents: 53742
diff changeset
1277 const char *s /* encoded string */
ac209f132b17 Issue #5915: Implement PEP 383, Non-decodable Bytes in
Martin v. Löwis <martin@v.loewis.de>
parents: 53742
diff changeset
1278 );
ac209f132b17 Issue #5915: Implement PEP 383, Non-decodable Bytes in
Martin v. Löwis <martin@v.loewis.de>
parents: 53742
diff changeset
1279
61577
2b0af69aef97 Merged revisions 81168 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 61467
diff changeset
1280 /* Decode a string using Py_FileSystemDefaultEncoding
2b0af69aef97 Merged revisions 81168 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 61467
diff changeset
1281 and the "surrogateescape" error handler.
2b0af69aef97 Merged revisions 81168 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 61467
diff changeset
1282
65348
453fd8182c2f Use locale encoding if Py_FileSystemDefaultEncoding is not set
Victor Stinner <victor.stinner@haypocalc.com>
parents: 65157
diff changeset
1283 If Py_FileSystemDefaultEncoding is not set, fall back to the locale
453fd8182c2f Use locale encoding if Py_FileSystemDefaultEncoding is not set
Victor Stinner <victor.stinner@haypocalc.com>
parents: 65157
diff changeset
1284 encoding.
61577
2b0af69aef97 Merged revisions 81168 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 61467
diff changeset
1285 */
2b0af69aef97 Merged revisions 81168 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 61467
diff changeset
1286
53767
ac209f132b17 Issue #5915: Implement PEP 383, Non-decodable Bytes in
Martin v. Löwis <martin@v.loewis.de>
parents: 53742
diff changeset
1287 PyAPI_FUNC(PyObject*) PyUnicode_DecodeFSDefaultAndSize(
ac209f132b17 Issue #5915: Implement PEP 383, Non-decodable Bytes in
Martin v. Löwis <martin@v.loewis.de>
parents: 53742
diff changeset
1288 const char *s, /* encoded string */
ac209f132b17 Issue #5915: Implement PEP 383, Non-decodable Bytes in
Martin v. Löwis <martin@v.loewis.de>
parents: 53742
diff changeset
1289 Py_ssize_t size /* size */
ac209f132b17 Issue #5915: Implement PEP 383, Non-decodable Bytes in
Martin v. Löwis <martin@v.loewis.de>
parents: 53742
diff changeset
1290 );
ac209f132b17 Issue #5915: Implement PEP 383, Non-decodable Bytes in
Martin v. Löwis <martin@v.loewis.de>
parents: 53742
diff changeset
1291
61597
b5ba7ea4246b Issue #8715: Create PyUnicode_EncodeFSDefault() function: Encode a Unicode
Victor Stinner <victor.stinner@haypocalc.com>
parents: 61576
diff changeset
1292 /* Encode a Unicode object to Py_FileSystemDefaultEncoding with the
61601
042e6a396a86 rephrase
Benjamin Peterson <benjamin@python.org>
parents: 61597
diff changeset
1293 "surrogateescape" error handler, and return bytes.
61597
b5ba7ea4246b Issue #8715: Create PyUnicode_EncodeFSDefault() function: Encode a Unicode
Victor Stinner <victor.stinner@haypocalc.com>
parents: 61576
diff changeset
1294
65348
453fd8182c2f Use locale encoding if Py_FileSystemDefaultEncoding is not set
Victor Stinner <victor.stinner@haypocalc.com>
parents: 65157
diff changeset
1295 If Py_FileSystemDefaultEncoding is not set, fall back to the locale
453fd8182c2f Use locale encoding if Py_FileSystemDefaultEncoding is not set
Victor Stinner <victor.stinner@haypocalc.com>
parents: 65157
diff changeset
1296 encoding.
61597
b5ba7ea4246b Issue #8715: Create PyUnicode_EncodeFSDefault() function: Encode a Unicode
Victor Stinner <victor.stinner@haypocalc.com>
parents: 61576
diff changeset
1297 */
b5ba7ea4246b Issue #8715: Create PyUnicode_EncodeFSDefault() function: Encode a Unicode
Victor Stinner <victor.stinner@haypocalc.com>
parents: 61576
diff changeset
1298
b5ba7ea4246b Issue #8715: Create PyUnicode_EncodeFSDefault() function: Encode a Unicode
Victor Stinner <victor.stinner@haypocalc.com>
parents: 61576
diff changeset
1299 PyAPI_FUNC(PyObject*) PyUnicode_EncodeFSDefault(
b5ba7ea4246b Issue #8715: Create PyUnicode_EncodeFSDefault() function: Encode a Unicode
Victor Stinner <victor.stinner@haypocalc.com>
parents: 61576
diff changeset
1300 PyObject *unicode
b5ba7ea4246b Issue #8715: Create PyUnicode_EncodeFSDefault() function: Encode a Unicode
Victor Stinner <victor.stinner@haypocalc.com>
parents: 61576
diff changeset
1301 );
b5ba7ea4246b Issue #8715: Create PyUnicode_EncodeFSDefault() function: Encode a Unicode
Victor Stinner <victor.stinner@haypocalc.com>
parents: 61576
diff changeset
1302
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1303 /* --- 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
1304
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1305 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
1306 (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
1307 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
1308
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1309 /* 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
1310
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1311 PyAPI_FUNC(PyObject*) PyUnicode_Concat(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1312 PyObject *left, /* Left string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1313 PyObject *right /* Right 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
1314 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1315
41769
b29d71d43c80 Add functions PyUnicode_Append() and PyUnicode_AppendAndDel() that mirror
Walter Dörwald <walter@livinglogic.de>
parents: 41768
diff changeset
1316 /* Concat two strings and put the result in *pleft
b29d71d43c80 Add functions PyUnicode_Append() and PyUnicode_AppendAndDel() that mirror
Walter Dörwald <walter@livinglogic.de>
parents: 41768
diff changeset
1317 (sets *pleft to NULL on error) */
b29d71d43c80 Add functions PyUnicode_Append() and PyUnicode_AppendAndDel() that mirror
Walter Dörwald <walter@livinglogic.de>
parents: 41768
diff changeset
1318
b29d71d43c80 Add functions PyUnicode_Append() and PyUnicode_AppendAndDel() that mirror
Walter Dörwald <walter@livinglogic.de>
parents: 41768
diff changeset
1319 PyAPI_FUNC(void) PyUnicode_Append(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1320 PyObject **pleft, /* Pointer to left string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1321 PyObject *right /* Right string */
41769
b29d71d43c80 Add functions PyUnicode_Append() and PyUnicode_AppendAndDel() that mirror
Walter Dörwald <walter@livinglogic.de>
parents: 41768
diff changeset
1322 );
b29d71d43c80 Add functions PyUnicode_Append() and PyUnicode_AppendAndDel() that mirror
Walter Dörwald <walter@livinglogic.de>
parents: 41768
diff changeset
1323
b29d71d43c80 Add functions PyUnicode_Append() and PyUnicode_AppendAndDel() that mirror
Walter Dörwald <walter@livinglogic.de>
parents: 41768
diff changeset
1324 /* Concat two strings, put the result in *pleft and drop the right object
b29d71d43c80 Add functions PyUnicode_Append() and PyUnicode_AppendAndDel() that mirror
Walter Dörwald <walter@livinglogic.de>
parents: 41768
diff changeset
1325 (sets *pleft to NULL on error) */
b29d71d43c80 Add functions PyUnicode_Append() and PyUnicode_AppendAndDel() that mirror
Walter Dörwald <walter@livinglogic.de>
parents: 41768
diff changeset
1326
b29d71d43c80 Add functions PyUnicode_Append() and PyUnicode_AppendAndDel() that mirror
Walter Dörwald <walter@livinglogic.de>
parents: 41768
diff changeset
1327 PyAPI_FUNC(void) PyUnicode_AppendAndDel(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1328 PyObject **pleft, /* Pointer to left string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1329 PyObject *right /* Right string */
41769
b29d71d43c80 Add functions PyUnicode_Append() and PyUnicode_AppendAndDel() that mirror
Walter Dörwald <walter@livinglogic.de>
parents: 41768
diff changeset
1330 );
b29d71d43c80 Add functions PyUnicode_Append() and PyUnicode_AppendAndDel() that mirror
Walter Dörwald <walter@livinglogic.de>
parents: 41768
diff changeset
1331
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1332 /* 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
1333
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1334 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
1335 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
1336
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1337 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
1338
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1339 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
1340
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1341 */
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1342
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1343 PyAPI_FUNC(PyObject*) PyUnicode_Split(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1344 PyObject *s, /* String to split */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1345 PyObject *sep, /* String separator */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1346 Py_ssize_t maxsplit /* Maxsplit count */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1347 );
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1348
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1349 /* 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
1350
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1351 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
1352 included in the resulting list. */
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1353
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1354 PyAPI_FUNC(PyObject*) PyUnicode_Splitlines(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1355 PyObject *s, /* String to split */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1356 int keepends /* If true, line end markers are included */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1357 );
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1358
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 36501
diff changeset
1359 /* Partition a string using a given separator. */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 36501
diff changeset
1360
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 36501
diff changeset
1361 PyAPI_FUNC(PyObject*) PyUnicode_Partition(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1362 PyObject *s, /* String to partition */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1363 PyObject *sep /* String separator */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1364 );
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 36501
diff changeset
1365
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 36501
diff changeset
1366 /* Partition a string using a given separator, searching from the end of the
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 36501
diff changeset
1367 string. */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 36501
diff changeset
1368
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 36501
diff changeset
1369 PyAPI_FUNC(PyObject*) PyUnicode_RPartition(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1370 PyObject *s, /* String to partition */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1371 PyObject *sep /* String separator */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1372 );
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 36501
diff changeset
1373
31199
504943c89193 Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 24753
diff changeset
1374 /* 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
1375
504943c89193 Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 24753
diff changeset
1376 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
1377 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
1378
504943c89193 Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 24753
diff changeset
1379 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
1380 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
1381 no limit is set.
504943c89193 Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 24753
diff changeset
1382
504943c89193 Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 24753
diff changeset
1383 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
1384
504943c89193 Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 24753
diff changeset
1385 */
504943c89193 Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 24753
diff changeset
1386
504943c89193 Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 24753
diff changeset
1387 PyAPI_FUNC(PyObject*) PyUnicode_RSplit(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1388 PyObject *s, /* String to split */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1389 PyObject *sep, /* String separator */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1390 Py_ssize_t maxsplit /* Maxsplit count */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1391 );
31199
504943c89193 Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 24753
diff changeset
1392
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1393 /* 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
1394 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
1395
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1396 The mapping table must map Unicode ordinal integers to Unicode
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1397 ordinal integers or None (causing deletion of the 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
1398
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1399 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
1400 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
1401 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
1402
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1403 */
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1404
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1405 PyAPI_FUNC(PyObject *) PyUnicode_Translate(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1406 PyObject *str, /* String */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1407 PyObject *table, /* Translate table */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1408 const char *errors /* error handling */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1409 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1410
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1411 /* 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
1412 the resulting Unicode string. */
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1413
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1414 PyAPI_FUNC(PyObject*) PyUnicode_Join(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1415 PyObject *separator, /* Separator string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1416 PyObject *seq /* Sequence object */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1417 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1418
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1419 /* 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
1420 otherwise. */
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1421
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 35808
diff changeset
1422 PyAPI_FUNC(Py_ssize_t) PyUnicode_Tailmatch(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1423 PyObject *str, /* String */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1424 PyObject *substr, /* Prefix or Suffix string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1425 Py_ssize_t start, /* Start index */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1426 Py_ssize_t end, /* Stop index */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1427 int direction /* Tail end: -1 prefix, +1 suffix */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1428 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1429
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1430 /* 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
1431 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
1432 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
1433
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 35808
diff changeset
1434 PyAPI_FUNC(Py_ssize_t) PyUnicode_Find(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1435 PyObject *str, /* String */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1436 PyObject *substr, /* Substring to find */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1437 Py_ssize_t start, /* Start index */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1438 Py_ssize_t end, /* Stop index */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1439 int direction /* Find direction: +1 forward, -1 backward */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1440 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1441
12025
7994d9db7f4d On 17-Mar-2000, Marc-Andre Lemburg said:
Barry Warsaw <barry@python.org>
parents: 12002
diff changeset
1442 /* 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
1443
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 35808
diff changeset
1444 PyAPI_FUNC(Py_ssize_t) PyUnicode_Count(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1445 PyObject *str, /* String */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1446 PyObject *substr, /* Substring to count */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1447 Py_ssize_t start, /* Start index */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1448 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
1449 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1450
12025
7994d9db7f4d On 17-Mar-2000, Marc-Andre Lemburg said:
Barry Warsaw <barry@python.org>
parents: 12002
diff changeset
1451 /* 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
1452 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
1453
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1454 PyAPI_FUNC(PyObject *) PyUnicode_Replace(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1455 PyObject *str, /* String */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1456 PyObject *substr, /* Substring to find */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1457 PyObject *replstr, /* Substring to replace */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1458 Py_ssize_t maxcount /* Max. number of replacements to apply;
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1459 -1 = all */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1460 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1461
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1462 /* 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
1463 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
1464
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1465 PyAPI_FUNC(int) PyUnicode_Compare(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1466 PyObject *left, /* Left string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1467 PyObject *right /* Right 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
1468 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1469
42013
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41876
diff changeset
1470 PyAPI_FUNC(int) PyUnicode_CompareWithASCIIString(
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41876
diff changeset
1471 PyObject *left,
67150
4bb7f7b151fe Issue #9738: document encodings of unicode functions
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66751
diff changeset
1472 const char *right /* ASCII-encoded string */
42013
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41876
diff changeset
1473 );
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41876
diff changeset
1474
39610
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1475 /* Rich compare two strings and return one of the following:
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1476
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1477 - NULL in case an exception was raised
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1478 - Py_True or Py_False for successfuly comparisons
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1479 - Py_NotImplemented in case the type combination is unknown
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1480
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1481 Note that Py_EQ and Py_NE comparisons can cause a UnicodeWarning in
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1482 case the conversion of the arguments to Unicode fails with a
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1483 UnicodeDecodeError.
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1484
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1485 Possible values for op:
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1486
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1487 Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1488
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1489 */
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1490
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1491 PyAPI_FUNC(PyObject *) PyUnicode_RichCompare(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1492 PyObject *left, /* Left string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1493 PyObject *right, /* Right string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1494 int op /* Operation: Py_EQ, Py_NE, Py_GT, etc. */
39610
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1495 );
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1496
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
1497 /* 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
1498 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
1499
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1500 PyAPI_FUNC(PyObject *) PyUnicode_Format(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1501 PyObject *format, /* Format string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1502 PyObject *args /* Argument tuple or dictionary */
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1503 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1504
12002
d50fa3670b66 Marc-Andre Lemburg: add declaration for PyUnicode_Contains().
Guido van Rossum <guido@python.org>
parents: 11962
diff changeset
1505 /* 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
1506 accordingly.
d50fa3670b66 Marc-Andre Lemburg: add declaration for PyUnicode_Contains().
Guido van Rossum <guido@python.org>
parents: 11962
diff changeset
1507
d50fa3670b66 Marc-Andre Lemburg: add declaration for PyUnicode_Contains().
Guido van Rossum <guido@python.org>
parents: 11962
diff changeset
1508 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
1509 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
1510
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1511 PyAPI_FUNC(int) PyUnicode_Contains(
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1512 PyObject *container, /* Container string */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1513 PyObject *element /* Element string */
12002
d50fa3670b66 Marc-Andre Lemburg: add declaration for PyUnicode_Contains().
Guido van Rossum <guido@python.org>
parents: 11962
diff changeset
1514 );
d50fa3670b66 Marc-Andre Lemburg: add declaration for PyUnicode_Contains().
Guido van Rossum <guido@python.org>
parents: 11962
diff changeset
1515
42597
20477cbfd996 Implement PEP 3131. Add isidentifier to str.
Martin v. Löwis <martin@v.loewis.de>
parents: 42595
diff changeset
1516 /* Checks whether argument is a valid identifier. */
20477cbfd996 Implement PEP 3131. Add isidentifier to str.
Martin v. Löwis <martin@v.loewis.de>
parents: 42595
diff changeset
1517
20477cbfd996 Implement PEP 3131. Add isidentifier to str.
Martin v. Löwis <martin@v.loewis.de>
parents: 42595
diff changeset
1518 PyAPI_FUNC(int) PyUnicode_IsIdentifier(PyObject *s);
20477cbfd996 Implement PEP 3131. Add isidentifier to str.
Martin v. Löwis <martin@v.loewis.de>
parents: 42595
diff changeset
1519
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1520 #ifndef Py_LIMITED_API
23225
e639e34ef901 Apply patch diff.txt from SF feature request
Walter Dörwald <walter@livinglogic.de>
parents: 20554
diff changeset
1521 /* Externally visible for str.strip(unicode) */
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1522 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
1523 PyUnicodeObject *self,
e639e34ef901 Apply patch diff.txt from SF feature request
Walter Dörwald <walter@livinglogic.de>
parents: 20554
diff changeset
1524 int striptype,
e639e34ef901 Apply patch diff.txt from SF feature request
Walter Dörwald <walter@livinglogic.de>
parents: 20554
diff changeset
1525 PyObject *sepobj
e639e34ef901 Apply patch diff.txt from SF feature request
Walter Dörwald <walter@livinglogic.de>
parents: 20554
diff changeset
1526 );
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1527 #endif
23225
e639e34ef901 Apply patch diff.txt from SF feature request
Walter Dörwald <walter@livinglogic.de>
parents: 20554
diff changeset
1528
46909
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46598
diff changeset
1529 /* Using the current locale, insert the thousands grouping
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46598
diff changeset
1530 into the string pointed to by buffer. For the argument descriptions,
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46598
diff changeset
1531 see Objects/stringlib/localeutil.h */
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46598
diff changeset
1532
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1533 #ifndef Py_LIMITED_API
53187
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
1534 PyAPI_FUNC(Py_ssize_t) _PyUnicode_InsertThousandsGroupingLocale(Py_UNICODE *buffer,
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
1535 Py_ssize_t n_buffer,
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
1536 Py_UNICODE *digits,
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
1537 Py_ssize_t n_digits,
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
1538 Py_ssize_t min_width);
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1539 #endif
46909
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46598
diff changeset
1540
52773
28096ed73153 Added ',' thousands grouping to int.__format__. See PEP 378.
Eric Smith <eric@trueblade.com>
parents: 50660
diff changeset
1541 /* Using explicit passed-in values, insert the thousands grouping
28096ed73153 Added ',' thousands grouping to int.__format__. See PEP 378.
Eric Smith <eric@trueblade.com>
parents: 50660
diff changeset
1542 into the string pointed to by buffer. For the argument descriptions,
28096ed73153 Added ',' thousands grouping to int.__format__. See PEP 378.
Eric Smith <eric@trueblade.com>
parents: 50660
diff changeset
1543 see Objects/stringlib/localeutil.h */
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1544 #ifndef Py_LIMITED_API
53187
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
1545 PyAPI_FUNC(Py_ssize_t) _PyUnicode_InsertThousandsGrouping(Py_UNICODE *buffer,
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
1546 Py_ssize_t n_buffer,
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
1547 Py_UNICODE *digits,
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
1548 Py_ssize_t n_digits,
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
1549 Py_ssize_t min_width,
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
1550 const char *grouping,
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
1551 const char *thousands_sep);
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1552 #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
1553 /* === 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
1554
50660
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
1555 /* Helper array used by Py_UNICODE_ISSPACE(). */
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
1556
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1557 #ifndef Py_LIMITED_API
50660
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
1558 PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[];
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 50550
diff changeset
1559
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1560 /* These should not be used directly. Use the Py_UNICODE_IS* and
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53767
diff changeset
1561 Py_UNICODE_TO* macros instead.
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1562
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1563 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
1564
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1565 */
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1566
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1567 PyAPI_FUNC(int) _PyUnicode_IsLowercase(
64146
8f97c64b2333 #5127: Even on narrow unicode builds, the C functions that access the Unicode
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 64081
diff changeset
1568 Py_UCS4 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
1569 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1570
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1571 PyAPI_FUNC(int) _PyUnicode_IsUppercase(
64146
8f97c64b2333 #5127: Even on narrow unicode builds, the C functions that access the Unicode
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 64081
diff changeset
1572 Py_UCS4 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
1573 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1574
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1575 PyAPI_FUNC(int) _PyUnicode_IsTitlecase(
64146
8f97c64b2333 #5127: Even on narrow unicode builds, the C functions that access the Unicode
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 64081
diff changeset
1576 Py_UCS4 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
1577 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1578
42595
f6af0b2598ca Add XID_Start and XID_Continue properties to unicodectype.
Martin v. Löwis <martin@v.loewis.de>
parents: 42490
diff changeset
1579 PyAPI_FUNC(int) _PyUnicode_IsXidStart(
64146
8f97c64b2333 #5127: Even on narrow unicode builds, the C functions that access the Unicode
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 64081
diff changeset
1580 Py_UCS4 ch /* Unicode character */
42595
f6af0b2598ca Add XID_Start and XID_Continue properties to unicodectype.
Martin v. Löwis <martin@v.loewis.de>
parents: 42490
diff changeset
1581 );
f6af0b2598ca Add XID_Start and XID_Continue properties to unicodectype.
Martin v. Löwis <martin@v.loewis.de>
parents: 42490
diff changeset
1582
f6af0b2598ca Add XID_Start and XID_Continue properties to unicodectype.
Martin v. Löwis <martin@v.loewis.de>
parents: 42490
diff changeset
1583 PyAPI_FUNC(int) _PyUnicode_IsXidContinue(
64146
8f97c64b2333 #5127: Even on narrow unicode builds, the C functions that access the Unicode
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 64081
diff changeset
1584 Py_UCS4 ch /* Unicode character */
42595
f6af0b2598ca Add XID_Start and XID_Continue properties to unicodectype.
Martin v. Löwis <martin@v.loewis.de>
parents: 42490
diff changeset
1585 );
f6af0b2598ca Add XID_Start and XID_Continue properties to unicodectype.
Martin v. Löwis <martin@v.loewis.de>
parents: 42490
diff changeset
1586
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1587 PyAPI_FUNC(int) _PyUnicode_IsWhitespace(
64146
8f97c64b2333 #5127: Even on narrow unicode builds, the C functions that access the Unicode
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 64081
diff changeset
1588 const Py_UCS4 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
1589 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1590
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1591 PyAPI_FUNC(int) _PyUnicode_IsLinebreak(
64146
8f97c64b2333 #5127: Even on narrow unicode builds, the C functions that access the Unicode
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 64081
diff changeset
1592 const Py_UCS4 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
1593 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1594
64146
8f97c64b2333 #5127: Even on narrow unicode builds, the C functions that access the Unicode
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 64081
diff changeset
1595 PyAPI_FUNC(Py_UCS4) _PyUnicode_ToLowercase(
8f97c64b2333 #5127: Even on narrow unicode builds, the C functions that access the Unicode
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 64081
diff changeset
1596 Py_UCS4 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
1597 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1598
64146
8f97c64b2333 #5127: Even on narrow unicode builds, the C functions that access the Unicode
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 64081
diff changeset
1599 PyAPI_FUNC(Py_UCS4) _PyUnicode_ToUppercase(
8f97c64b2333 #5127: Even on narrow unicode builds, the C functions that access the Unicode
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 64081
diff changeset
1600 Py_UCS4 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
1601 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1602
64146
8f97c64b2333 #5127: Even on narrow unicode builds, the C functions that access the Unicode
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 64081
diff changeset
1603 PyAPI_FUNC(Py_UCS4) _PyUnicode_ToTitlecase(
8f97c64b2333 #5127: Even on narrow unicode builds, the C functions that access the Unicode
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 64081
diff changeset
1604 Py_UCS4 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
1605 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1606
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1607 PyAPI_FUNC(int) _PyUnicode_ToDecimalDigit(
64146
8f97c64b2333 #5127: Even on narrow unicode builds, the C functions that access the Unicode
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 64081
diff changeset
1608 Py_UCS4 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
1609 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1610
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1611 PyAPI_FUNC(int) _PyUnicode_ToDigit(
64146
8f97c64b2333 #5127: Even on narrow unicode builds, the C functions that access the Unicode
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 64081
diff changeset
1612 Py_UCS4 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
1613 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1614
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1615 PyAPI_FUNC(double) _PyUnicode_ToNumeric(
64146
8f97c64b2333 #5127: Even on narrow unicode builds, the C functions that access the Unicode
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 64081
diff changeset
1616 Py_UCS4 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
1617 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1618
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1619 PyAPI_FUNC(int) _PyUnicode_IsDecimalDigit(
64146
8f97c64b2333 #5127: Even on narrow unicode builds, the C functions that access the Unicode
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 64081
diff changeset
1620 Py_UCS4 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
1621 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1622
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1623 PyAPI_FUNC(int) _PyUnicode_IsDigit(
64146
8f97c64b2333 #5127: Even on narrow unicode builds, the C functions that access the Unicode
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 64081
diff changeset
1624 Py_UCS4 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
1625 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1626
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1627 PyAPI_FUNC(int) _PyUnicode_IsNumeric(
64146
8f97c64b2333 #5127: Even on narrow unicode builds, the C functions that access the Unicode
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 64081
diff changeset
1628 Py_UCS4 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
1629 );
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1630
47611
da47e7e135ae #2630: Implement PEP 3138.
Georg Brandl <georg@python.org>
parents: 47496
diff changeset
1631 PyAPI_FUNC(int) _PyUnicode_IsPrintable(
64146
8f97c64b2333 #5127: Even on narrow unicode builds, the C functions that access the Unicode
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 64081
diff changeset
1632 Py_UCS4 ch /* Unicode character */
47611
da47e7e135ae #2630: Implement PEP 3138.
Georg Brandl <georg@python.org>
parents: 47496
diff changeset
1633 );
da47e7e135ae #2630: Implement PEP 3138.
Georg Brandl <georg@python.org>
parents: 47496
diff changeset
1634
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24737
diff changeset
1635 PyAPI_FUNC(int) _PyUnicode_IsAlpha(
64146
8f97c64b2333 #5127: Even on narrow unicode builds, the C functions that access the Unicode
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 64081
diff changeset
1636 Py_UCS4 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
1637 );
d88535ccaee5 Modified the ISALPHA and ISALNUM macros to use the new lookup APIs
Marc-André Lemburg <mal@egenix.com>
parents: 13320
diff changeset
1638
64081
b089ed576b13 Issue #9425: Create Py_UNICODE_strncmp() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63963
diff changeset
1639 PyAPI_FUNC(size_t) Py_UNICODE_strlen(
b089ed576b13 Issue #9425: Create Py_UNICODE_strncmp() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63963
diff changeset
1640 const Py_UNICODE *u
b089ed576b13 Issue #9425: Create Py_UNICODE_strncmp() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63963
diff changeset
1641 );
42013
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41876
diff changeset
1642
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41876
diff changeset
1643 PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strcpy(
64081
b089ed576b13 Issue #9425: Create Py_UNICODE_strncmp() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63963
diff changeset
1644 Py_UNICODE *s1,
b089ed576b13 Issue #9425: Create Py_UNICODE_strncmp() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63963
diff changeset
1645 const Py_UNICODE *s2);
42013
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41876
diff changeset
1646
64372
a0d8de04c3a8 Create Py_UNICODE_strcat() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64349
diff changeset
1647 PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strcat(
42013
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41876
diff changeset
1648 Py_UNICODE *s1, const Py_UNICODE *s2);
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41876
diff changeset
1649
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41876
diff changeset
1650 PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strncpy(
64081
b089ed576b13 Issue #9425: Create Py_UNICODE_strncmp() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63963
diff changeset
1651 Py_UNICODE *s1,
b089ed576b13 Issue #9425: Create Py_UNICODE_strncmp() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63963
diff changeset
1652 const Py_UNICODE *s2,
b089ed576b13 Issue #9425: Create Py_UNICODE_strncmp() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63963
diff changeset
1653 size_t n);
42013
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41876
diff changeset
1654
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41876
diff changeset
1655 PyAPI_FUNC(int) Py_UNICODE_strcmp(
64081
b089ed576b13 Issue #9425: Create Py_UNICODE_strncmp() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63963
diff changeset
1656 const Py_UNICODE *s1,
b089ed576b13 Issue #9425: Create Py_UNICODE_strncmp() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63963
diff changeset
1657 const Py_UNICODE *s2
b089ed576b13 Issue #9425: Create Py_UNICODE_strncmp() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63963
diff changeset
1658 );
b089ed576b13 Issue #9425: Create Py_UNICODE_strncmp() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63963
diff changeset
1659
b089ed576b13 Issue #9425: Create Py_UNICODE_strncmp() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63963
diff changeset
1660 PyAPI_FUNC(int) Py_UNICODE_strncmp(
b089ed576b13 Issue #9425: Create Py_UNICODE_strncmp() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63963
diff changeset
1661 const Py_UNICODE *s1,
b089ed576b13 Issue #9425: Create Py_UNICODE_strncmp() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63963
diff changeset
1662 const Py_UNICODE *s2,
b089ed576b13 Issue #9425: Create Py_UNICODE_strncmp() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63963
diff changeset
1663 size_t n
b089ed576b13 Issue #9425: Create Py_UNICODE_strncmp() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63963
diff changeset
1664 );
42013
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41876
diff changeset
1665
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41876
diff changeset
1666 PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strchr(
64081
b089ed576b13 Issue #9425: Create Py_UNICODE_strncmp() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63963
diff changeset
1667 const Py_UNICODE *s,
b089ed576b13 Issue #9425: Create Py_UNICODE_strncmp() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63963
diff changeset
1668 Py_UNICODE c
42013
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41876
diff changeset
1669 );
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41876
diff changeset
1670
63912
a3853bfa2518 Issue #9425: create Py_UNICODE_strrchr() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 62530
diff changeset
1671 PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strrchr(
64081
b089ed576b13 Issue #9425: Create Py_UNICODE_strncmp() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63963
diff changeset
1672 const Py_UNICODE *s,
b089ed576b13 Issue #9425: Create Py_UNICODE_strncmp() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63963
diff changeset
1673 Py_UNICODE c
42013
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41876
diff changeset
1674 );
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41876
diff changeset
1675
64373
1f04b0076fd8 Create PyUnicode_strdup() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64372
diff changeset
1676 /* Create a copy of a unicode string ending with a nul character. Return NULL
1f04b0076fd8 Create PyUnicode_strdup() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64372
diff changeset
1677 and raise a MemoryError exception on memory allocation failure, otherwise
1f04b0076fd8 Create PyUnicode_strdup() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64372
diff changeset
1678 return a new allocated buffer (use PyMem_Free() to free the buffer). */
1f04b0076fd8 Create PyUnicode_strdup() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64372
diff changeset
1679
64397
98f337a6957c Rename PyUnicode_strdup() to PyUnicode_AsUnicodeCopy()
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64373
diff changeset
1680 PyAPI_FUNC(Py_UNICODE*) PyUnicode_AsUnicodeCopy(
64373
1f04b0076fd8 Create PyUnicode_strdup() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64372
diff changeset
1681 PyObject *unicode
1f04b0076fd8 Create PyUnicode_strdup() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64372
diff changeset
1682 );
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66203
diff changeset
1683 #endif /* Py_LIMITED_API */
64373
1f04b0076fd8 Create PyUnicode_strdup() function
Victor Stinner <victor.stinner@haypocalc.com>
parents: 64372
diff changeset
1684
11962
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1685 #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
1686 }
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1687 #endif
be98e055e39d Unicode implementation by Marc-Andre Lemburg based on original code by Fredrik Lundh.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1688 #endif /* !Py_UNICODEOBJECT_H */