Mercurial > cpython-lru_cache-weakref
annotate Include/codecs.h @ 73807:1efefeda00a7 3.2
#8414: add more tests for "assert". Initial patch by Gregory Nofi.
| author | Ezio Melotti <ezio.melotti@gmail.com> |
|---|---|
| date | Fri, 02 Dec 2011 18:22:52 +0200 |
| parents | 62b61abd02b8 |
| children | d76338eacf7c |
| 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 |
|
66664
62b61abd02b8
Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents:
66277
diff
changeset
|
48 #ifndef Py_LIMITED_API |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
13828
diff
changeset
|
49 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
|
50 const char *encoding |
|
9d53fc8043ba
Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
51 ); |
|
66664
62b61abd02b8
Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents:
66277
diff
changeset
|
52 #endif |
|
11961
9d53fc8043ba
Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
53 |
|
47496
2284fa89ab08
Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents:
37875
diff
changeset
|
54 /* 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
|
55 |
|
2284fa89ab08
Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents:
37875
diff
changeset
|
56 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
|
57 the given encoding. |
|
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 */ |
|
2284fa89ab08
Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents:
37875
diff
changeset
|
60 |
|
2284fa89ab08
Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents:
37875
diff
changeset
|
61 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
|
62 const char *encoding |
|
2284fa89ab08
Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents:
37875
diff
changeset
|
63 ); |
|
2284fa89ab08
Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents:
37875
diff
changeset
|
64 |
|
12642
91b2ec207633
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
11961
diff
changeset
|
65 /* Generic codec based encoding API. |
|
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 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
|
68 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
|
69 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
|
70 |
|
91b2ec207633
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
11961
diff
changeset
|
71 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
|
72 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
13828
diff
changeset
|
75 PyAPI_FUNC(PyObject *) PyCodec_Encode( |
|
12642
91b2ec207633
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
11961
diff
changeset
|
76 PyObject *object, |
|
91b2ec207633
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
11961
diff
changeset
|
77 const char *encoding, |
|
91b2ec207633
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
11961
diff
changeset
|
78 const char *errors |
|
91b2ec207633
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
11961
diff
changeset
|
79 ); |
|
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 /* Generic codec based decoding API. |
|
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 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
|
84 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
|
85 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
|
86 |
|
91b2ec207633
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
11961
diff
changeset
|
87 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
|
88 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
13828
diff
changeset
|
91 PyAPI_FUNC(PyObject *) PyCodec_Decode( |
|
12642
91b2ec207633
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
11961
diff
changeset
|
92 PyObject *object, |
|
91b2ec207633
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
11961
diff
changeset
|
93 const char *encoding, |
|
91b2ec207633
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
11961
diff
changeset
|
94 const char *errors |
|
91b2ec207633
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
11961
diff
changeset
|
95 ); |
|
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 /* --- Codec Lookup APIs -------------------------------------------------- |
|
91b2ec207633
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
11961
diff
changeset
|
98 |
|
91b2ec207633
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
11961
diff
changeset
|
99 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
|
100 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
|
101 name also apply to these APIs. |
|
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 */ |
|
91b2ec207633
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
11961
diff
changeset
|
104 |
|
91b2ec207633
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
11961
diff
changeset
|
105 /* Get an encoder function for the given encoding. */ |
|
91b2ec207633
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
11961
diff
changeset
|
106 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
13828
diff
changeset
|
107 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
|
108 const char *encoding |
|
9d53fc8043ba
Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
109 ); |
|
9d53fc8043ba
Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
110 |
|
12642
91b2ec207633
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
11961
diff
changeset
|
111 /* Get a decoder function for the given encoding. */ |
|
91b2ec207633
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
11961
diff
changeset
|
112 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
13828
diff
changeset
|
113 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
|
114 const char *encoding |
|
9d53fc8043ba
Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
115 ); |
|
9d53fc8043ba
Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
116 |
|
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
|
117 /* 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
|
118 |
|
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 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
|
120 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
|
121 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
|
122 ); |
|
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 /* 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
|
125 |
|
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 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
|
127 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
|
128 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
|
129 ); |
|
a4c70f3968be
Merge part of the trunk changes into the p3yk branch. This merges from 43030
Thomas Wouters <thomas@python.org>
parents:
25091
diff
changeset
|
130 |
|
12642
91b2ec207633
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
11961
diff
changeset
|
131 /* 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
|
132 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
13828
diff
changeset
|
133 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
|
134 const char *encoding, |
|
9d53fc8043ba
Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
135 PyObject *stream, |
|
9d53fc8043ba
Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
136 const char *errors |
|
9d53fc8043ba
Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
137 ); |
|
9d53fc8043ba
Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
138 |
|
12642
91b2ec207633
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
11961
diff
changeset
|
139 /* 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
|
140 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
13828
diff
changeset
|
141 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
|
142 const char *encoding, |
|
12642
91b2ec207633
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
11961
diff
changeset
|
143 PyObject *stream, |
|
11961
9d53fc8043ba
Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
144 const char *errors |
|
9d53fc8043ba
Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
145 ); |
|
9d53fc8043ba
Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
146 |
|
25091
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24752
diff
changeset
|
147 /* 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
|
148 |
|
66277
debc76641912
#10439: document PyCodec C APIs.
Georg Brandl <georg@python.org>
parents:
47496
diff
changeset
|
149 /* 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
|
150 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
|
151 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
|
152 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
|
153 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
|
154 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
|
155 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
|
156 |
|
66277
debc76641912
#10439: document PyCodec C APIs.
Georg Brandl <georg@python.org>
parents:
47496
diff
changeset
|
157 /* Lookup the error handling callback function registered under the given |
|
debc76641912
#10439: document PyCodec C APIs.
Georg Brandl <georg@python.org>
parents:
47496
diff
changeset
|
158 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
|
159 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
|
160 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
|
161 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24752
diff
changeset
|
162 /* 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
|
163 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
|
164 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24752
diff
changeset
|
165 /* 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
|
166 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
|
167 |
|
66277
debc76641912
#10439: document PyCodec C APIs.
Georg Brandl <georg@python.org>
parents:
47496
diff
changeset
|
168 /* 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
|
169 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
|
170 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24752
diff
changeset
|
171 /* 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
|
172 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
|
173 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24752
diff
changeset
|
174 /* 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
|
175 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
|
176 |
|
11961
9d53fc8043ba
Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
177 #ifdef __cplusplus |
|
9d53fc8043ba
Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
178 } |
|
9d53fc8043ba
Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
179 #endif |
|
9d53fc8043ba
Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
180 #endif /* !Py_CODECREGISTRY_H */ |
