annotate Include/codecs.h @ 64166:d0e9febfa00a 3.1

Merged revisions 84172 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r84172 | martin.v.loewis | 2010-08-18 18:12:23 +0200 (Mi, 18 Aug 2010) | 2 lines Restore GIL in nis_cat in case of error. ........
author Martin v. Löwis <martin@v.loewis.de>
date Thu, 19 Aug 2010 09:03:03 +0000
parents 2284fa89ab08
children debc76641912
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
47496
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 37875
diff changeset
30 /* Codec registry lookup API.
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
31
37875
a4c70f3968be Merge part of the trunk changes into the p3yk branch. This merges from 43030
Thomas Wouters <thomas@python.org>
parents: 25091
diff changeset
32 Looks up the given encoding and returns a CodecInfo object with
a4c70f3968be Merge part of the trunk changes into the p3yk branch. This merges from 43030
Thomas Wouters <thomas@python.org>
parents: 25091
diff changeset
33 function attributes which implement the different aspects of
a4c70f3968be Merge part of the trunk changes into the p3yk branch. This merges from 43030
Thomas Wouters <thomas@python.org>
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
37875
a4c70f3968be Merge part of the trunk changes into the p3yk branch. This merges from 43030
Thomas Wouters <thomas@python.org>
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
47496
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 37875
diff changeset
52 /* Codec registry encoding check API.
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 37875
diff changeset
53
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 37875
diff changeset
54 Returns 1/0 depending on whether there is a registered codec for
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 37875
diff changeset
55 the given encoding.
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 37875
diff changeset
56
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 37875
diff changeset
57 */
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 37875
diff changeset
58
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 37875
diff changeset
59 PyAPI_FUNC(int) PyCodec_KnownEncoding(
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 37875
diff changeset
60 const char *encoding
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 37875
diff changeset
61 );
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 37875
diff changeset
62
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
63 /* Generic codec based encoding API.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
64
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
65 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
66 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
67 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
68
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
69 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
70
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
71 */
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
72
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 13828
diff changeset
73 PyAPI_FUNC(PyObject *) PyCodec_Encode(
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
74 PyObject *object,
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
75 const char *encoding,
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
76 const char *errors
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
77 );
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
78
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
79 /* Generic codec based decoding API.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
80
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
81 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
82 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
83 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
84
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
85 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
86
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
87 */
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
88
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 13828
diff changeset
89 PyAPI_FUNC(PyObject *) PyCodec_Decode(
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
90 PyObject *object,
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
91 const char *encoding,
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
92 const char *errors
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
93 );
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
94
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
95 /* --- Codec Lookup APIs --------------------------------------------------
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
96
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
97 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
98 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
99 name also apply to these APIs.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
100
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
101 */
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
102
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
103 /* Get an encoder function for the given encoding. */
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
104
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 13828
diff changeset
105 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
106 const char *encoding
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
107 );
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
108
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
109 /* Get a decoder function for the given encoding. */
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
110
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 13828
diff changeset
111 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
112 const char *encoding
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
113 );
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
114
37875
a4c70f3968be Merge part of the trunk changes into the p3yk branch. This merges from 43030
Thomas Wouters <thomas@python.org>
parents: 25091
diff changeset
115 /* Get a IncrementalEncoder object for the given encoding. */
a4c70f3968be Merge part of the trunk changes into the p3yk branch. This merges from 43030
Thomas Wouters <thomas@python.org>
parents: 25091
diff changeset
116
a4c70f3968be Merge part of the trunk changes into the p3yk branch. This merges from 43030
Thomas Wouters <thomas@python.org>
parents: 25091
diff changeset
117 PyAPI_FUNC(PyObject *) PyCodec_IncrementalEncoder(
a4c70f3968be Merge part of the trunk changes into the p3yk branch. This merges from 43030
Thomas Wouters <thomas@python.org>
parents: 25091
diff changeset
118 const char *encoding,
a4c70f3968be Merge part of the trunk changes into the p3yk branch. This merges from 43030
Thomas Wouters <thomas@python.org>
parents: 25091
diff changeset
119 const char *errors
a4c70f3968be Merge part of the trunk changes into the p3yk branch. This merges from 43030
Thomas Wouters <thomas@python.org>
parents: 25091
diff changeset
120 );
a4c70f3968be Merge part of the trunk changes into the p3yk branch. This merges from 43030
Thomas Wouters <thomas@python.org>
parents: 25091
diff changeset
121
a4c70f3968be Merge part of the trunk changes into the p3yk branch. This merges from 43030
Thomas Wouters <thomas@python.org>
parents: 25091
diff changeset
122 /* Get a IncrementalDecoder object function for the given encoding. */
a4c70f3968be Merge part of the trunk changes into the p3yk branch. This merges from 43030
Thomas Wouters <thomas@python.org>
parents: 25091
diff changeset
123
a4c70f3968be Merge part of the trunk changes into the p3yk branch. This merges from 43030
Thomas Wouters <thomas@python.org>
parents: 25091
diff changeset
124 PyAPI_FUNC(PyObject *) PyCodec_IncrementalDecoder(
a4c70f3968be Merge part of the trunk changes into the p3yk branch. This merges from 43030
Thomas Wouters <thomas@python.org>
parents: 25091
diff changeset
125 const char *encoding,
a4c70f3968be Merge part of the trunk changes into the p3yk branch. This merges from 43030
Thomas Wouters <thomas@python.org>
parents: 25091
diff changeset
126 const char *errors
a4c70f3968be Merge part of the trunk changes into the p3yk branch. This merges from 43030
Thomas Wouters <thomas@python.org>
parents: 25091
diff changeset
127 );
a4c70f3968be Merge part of the trunk changes into the p3yk branch. This merges from 43030
Thomas Wouters <thomas@python.org>
parents: 25091
diff changeset
128
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
129 /* 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
130
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 13828
diff changeset
131 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
132 const char *encoding,
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
133 PyObject *stream,
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
134 const char *errors
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
135 );
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
136
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
137 /* 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
138
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 13828
diff changeset
139 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
140 const char *encoding,
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
141 PyObject *stream,
11961
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
142 const char *errors
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
143 );
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
144
25091
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
145 /* 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
146
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
147 /* Register the error handling callback function error under the 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 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
149 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
150 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
151 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
152 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
153 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
154
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
155 /* Lookup the error handling callback function registered under the
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
156 name error. As a special case NULL can be passed, in which case
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
157 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
158 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
159
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
160 /* 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
161 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
162
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
163 /* 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
164 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
165
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
166 /* replace the unicode error with ? or U+FFFD */
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
167 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
168
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
169 /* 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
170 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
171
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
172 /* 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
173 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
174
11961
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
175 #ifdef __cplusplus
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
176 }
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
177 #endif
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
178 #endif /* !Py_CODECREGISTRY_H */