annotate Include/codecs.h @ 80661:94de77bd0b4b 2.7

Issue #16194: document imp.load_dynamic problems when read several extension modules from the same binary object file.
author Andrew Svetlov <andrew.svetlov@gmail.com>
date Thu, 29 Nov 2012 19:51:28 +0200
parents 7c0eb8d56146
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11961
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 #ifndef Py_CODECREGISTRY_H
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 #define Py_CODECREGISTRY_H
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 #ifdef __cplusplus
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 extern "C" {
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 #endif
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
6
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 /* ------------------------------------------------------------------------
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
8
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 Python Codec Registry and support functions
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
10
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
11
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 Written by Marc-Andre Lemburg (mal@lemburg.com).
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
13
13828
254f8b7c4a83 Changing the CNRI copyright notice according to CNRI's instructions.
Guido van Rossum <guido@python.org>
parents: 12642
diff changeset
14 Copyright (c) Corporation for National Research Initiatives.
11961
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
15
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 ------------------------------------------------------------------------ */
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
17
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
18 /* Register a new codec search function.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
19
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
20 As side effect, this tries to load the encodings package, if not
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
21 yet done, to make sure that it is always first in the list of
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
22 search functions.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
23
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
24 The search_function's refcount is incremented by this function. */
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
25
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 13828
diff changeset
26 PyAPI_FUNC(int) PyCodec_Register(
11961
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 PyObject *search_function
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 );
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
29
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
30 /* Codec register lookup API.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
31
36996
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
32 Looks up the given encoding and returns a CodecInfo object with
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
33 function attributes which implement the different aspects of
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
34 processing the encoding.
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
35
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
36 The encoding string is looked up converted to all lower-case
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
37 characters. This makes encodings looked up through this mechanism
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
38 effectively case-insensitive.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
39
36996
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
40 If no codec is found, a KeyError is set and NULL returned.
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
41
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
42 As side effect, this tries to load the encodings package, if not
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
43 yet done. This is part of the lazy load strategy for the encodings
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
44 package.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
45
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
46 */
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
47
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 13828
diff changeset
48 PyAPI_FUNC(PyObject *) _PyCodec_Lookup(
11961
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
49 const char *encoding
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 );
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
51
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
52 /* Generic codec based encoding API.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
53
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
54 object is passed through the encoder function found for the given
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
55 encoding using the error handling method defined by errors. errors
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
56 may be NULL to use the default method defined for the codec.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
57
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
58 Raises a LookupError in case no encoder can be found.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
59
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
60 */
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
61
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 13828
diff changeset
62 PyAPI_FUNC(PyObject *) PyCodec_Encode(
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
63 PyObject *object,
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
64 const char *encoding,
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
65 const char *errors
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
66 );
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
67
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
68 /* Generic codec based decoding API.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
69
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
70 object is passed through the decoder function found for the given
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
71 encoding using the error handling method defined by errors. errors
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
72 may be NULL to use the default method defined for the codec.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
73
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
74 Raises a LookupError in case no encoder can be found.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
75
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
76 */
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
77
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 13828
diff changeset
78 PyAPI_FUNC(PyObject *) PyCodec_Decode(
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
79 PyObject *object,
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
80 const char *encoding,
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
81 const char *errors
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
82 );
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
83
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
84 /* --- Codec Lookup APIs --------------------------------------------------
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
85
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
86 All APIs return a codec object with incremented refcount and are
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
87 based on _PyCodec_Lookup(). The same comments w/r to the encoding
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
88 name also apply to these APIs.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
89
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
90 */
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
91
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
92 /* Get an encoder function for the given encoding. */
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
93
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 13828
diff changeset
94 PyAPI_FUNC(PyObject *) PyCodec_Encoder(
11961
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
95 const char *encoding
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
96 );
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
97
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
98 /* Get a decoder function for the given encoding. */
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
99
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 13828
diff changeset
100 PyAPI_FUNC(PyObject *) PyCodec_Decoder(
11961
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
101 const char *encoding
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
102 );
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
103
36996
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
104 /* Get a IncrementalEncoder object for the given encoding. */
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
105
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
106 PyAPI_FUNC(PyObject *) PyCodec_IncrementalEncoder(
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
107 const char *encoding,
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
108 const char *errors
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
109 );
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
110
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
111 /* Get a IncrementalDecoder object function for the given encoding. */
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
112
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
113 PyAPI_FUNC(PyObject *) PyCodec_IncrementalDecoder(
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
114 const char *encoding,
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
115 const char *errors
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
116 );
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
117
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
118 /* Get a StreamReader factory function for the given encoding. */
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
119
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 13828
diff changeset
120 PyAPI_FUNC(PyObject *) PyCodec_StreamReader(
11961
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
121 const char *encoding,
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
122 PyObject *stream,
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
123 const char *errors
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
124 );
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
125
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
126 /* Get a StreamWriter factory function for the given encoding. */
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
127
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 13828
diff changeset
128 PyAPI_FUNC(PyObject *) PyCodec_StreamWriter(
11961
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
129 const char *encoding,
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
130 PyObject *stream,
11961
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
131 const char *errors
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
132 );
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
133
25091
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
134 /* Unicode encoding error handling callback registry API */
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
135
66467
7c0eb8d56146 Merged revisions 86561-86562,86564-86565,86705,86708,86713 via svnmerge from
Georg Brandl <georg@python.org>
parents: 36996
diff changeset
136 /* Register the error handling callback function error under the given
25091
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
137 name. This function will be called by the codec when it encounters
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
138 unencodable characters/undecodable bytes and doesn't know the
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
139 callback name, when name is specified as the error parameter
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
140 in the call to the encode/decode function.
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
141 Return 0 on success, -1 on error */
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
142 PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error);
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
143
66467
7c0eb8d56146 Merged revisions 86561-86562,86564-86565,86705,86708,86713 via svnmerge from
Georg Brandl <georg@python.org>
parents: 36996
diff changeset
144 /* Lookup the error handling callback function registered under the given
7c0eb8d56146 Merged revisions 86561-86562,86564-86565,86705,86708,86713 via svnmerge from
Georg Brandl <georg@python.org>
parents: 36996
diff changeset
145 name. As a special case NULL can be passed, in which case
25091
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
146 the error handling callback for "strict" will be returned. */
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
147 PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name);
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
148
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
149 /* raise exc as an exception */
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
150 PyAPI_FUNC(PyObject *) PyCodec_StrictErrors(PyObject *exc);
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
151
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
152 /* ignore the unicode error, skipping the faulty input */
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
153 PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc);
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
154
66467
7c0eb8d56146 Merged revisions 86561-86562,86564-86565,86705,86708,86713 via svnmerge from
Georg Brandl <georg@python.org>
parents: 36996
diff changeset
155 /* replace the unicode encode error with ? or U+FFFD */
25091
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
156 PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc);
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
157
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
158 /* replace the unicode encode error with XML character references */
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
159 PyAPI_FUNC(PyObject *) PyCodec_XMLCharRefReplaceErrors(PyObject *exc);
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
160
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
161 /* replace the unicode encode error with backslash escapes (\x, \u and \U) */
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
162 PyAPI_FUNC(PyObject *) PyCodec_BackslashReplaceErrors(PyObject *exc);
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
163
11961
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
164 #ifdef __cplusplus
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
165 }
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
166 #endif
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
167 #endif /* !Py_CODECREGISTRY_H */