Mercurial > cpython-lru_cache-weakref
annotate Doc/lib/libcodecs.tex @ 38664:7619216bbc19 2.4
Bug #1502728: Correctly link against librt library on HP-UX.
(backport from rev. 46743)
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Thu, 08 Jun 2006 12:54:16 +0000 |
| parents | 8102557afdf1 |
| children |
| rev | line source |
|---|---|
|
12260
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
1 \section{\module{codecs} --- |
|
12274
559b25a79032
Make sure the \declaremodule uses the right name for the module!
Fred Drake <fdrake@acm.org>
parents:
12260
diff
changeset
|
2 Codec registry and base classes} |
|
12260
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
3 |
|
12274
559b25a79032
Make sure the \declaremodule uses the right name for the module!
Fred Drake <fdrake@acm.org>
parents:
12260
diff
changeset
|
4 \declaremodule{standard}{codecs} |
|
12260
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
5 \modulesynopsis{Encode and decode data and streams.} |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
6 \moduleauthor{Marc-Andre Lemburg}{mal@lemburg.com} |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
7 \sectionauthor{Marc-Andre Lemburg}{mal@lemburg.com} |
|
28671
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
8 \sectionauthor{Martin v. L\"owis}{martin@v.loewis.de} |
|
12260
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
9 |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
10 \index{Unicode} |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
11 \index{Codecs} |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
12 \indexii{Codecs}{encode} |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
13 \indexii{Codecs}{decode} |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
14 \index{streams} |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
15 \indexii{stackable}{streams} |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
16 |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
17 |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
18 This module defines base classes for standard Python codecs (encoders |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
19 and decoders) and provides access to the internal Python codec |
|
25091
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
20 registry which manages the codec and error handling lookup process. |
|
12260
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
21 |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
22 It defines the following functions: |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
23 |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
24 \begin{funcdesc}{register}{search_function} |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
25 Register a codec search function. Search functions are expected to |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
26 take one argument, the encoding name in all lower case letters, and |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
27 return a tuple of functions \code{(\var{encoder}, \var{decoder}, \var{stream_reader}, |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
28 \var{stream_writer})} taking the following arguments: |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
29 |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
30 \var{encoder} and \var{decoder}: These must be functions or methods |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
31 which have the same interface as the |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
32 \method{encode()}/\method{decode()} methods of Codec instances (see |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
33 Codec Interface). The functions/methods are expected to work in a |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
34 stateless mode. |
|
12260
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
35 |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
36 \var{stream_reader} and \var{stream_writer}: These have to be |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
37 factory functions providing the following interface: |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
38 |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
39 \code{factory(\var{stream}, \var{errors}='strict')} |
|
12260
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
40 |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
41 The factory functions must return objects providing the interfaces |
|
12274
559b25a79032
Make sure the \declaremodule uses the right name for the module!
Fred Drake <fdrake@acm.org>
parents:
12260
diff
changeset
|
42 defined by the base classes \class{StreamWriter} and |
|
559b25a79032
Make sure the \declaremodule uses the right name for the module!
Fred Drake <fdrake@acm.org>
parents:
12260
diff
changeset
|
43 \class{StreamReader}, respectively. Stream codecs can maintain |
|
559b25a79032
Make sure the \declaremodule uses the right name for the module!
Fred Drake <fdrake@acm.org>
parents:
12260
diff
changeset
|
44 state. |
|
12260
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
45 |
|
12274
559b25a79032
Make sure the \declaremodule uses the right name for the module!
Fred Drake <fdrake@acm.org>
parents:
12260
diff
changeset
|
46 Possible values for errors are \code{'strict'} (raise an exception |
|
559b25a79032
Make sure the \declaremodule uses the right name for the module!
Fred Drake <fdrake@acm.org>
parents:
12260
diff
changeset
|
47 in case of an encoding error), \code{'replace'} (replace malformed |
|
26294
6d0cd80e2804
Document additional error handling names available through PEP 293.
Walter Dörwald <walter@livinglogic.de>
parents:
26099
diff
changeset
|
48 data with a suitable replacement marker, such as \character{?}), |
|
12274
559b25a79032
Make sure the \declaremodule uses the right name for the module!
Fred Drake <fdrake@acm.org>
parents:
12260
diff
changeset
|
49 \code{'ignore'} (ignore malformed data and continue without further |
|
26294
6d0cd80e2804
Document additional error handling names available through PEP 293.
Walter Dörwald <walter@livinglogic.de>
parents:
26099
diff
changeset
|
50 notice), \code{'xmlcharrefreplace'} (replace with the appropriate XML |
|
6d0cd80e2804
Document additional error handling names available through PEP 293.
Walter Dörwald <walter@livinglogic.de>
parents:
26099
diff
changeset
|
51 character reference (for encoding only)) and \code{'backslashreplace'} |
|
6d0cd80e2804
Document additional error handling names available through PEP 293.
Walter Dörwald <walter@livinglogic.de>
parents:
26099
diff
changeset
|
52 (replace with backslashed escape sequences (for encoding only)) as |
|
6d0cd80e2804
Document additional error handling names available through PEP 293.
Walter Dörwald <walter@livinglogic.de>
parents:
26099
diff
changeset
|
53 well as any other error handling name defined via |
|
6d0cd80e2804
Document additional error handling names available through PEP 293.
Walter Dörwald <walter@livinglogic.de>
parents:
26099
diff
changeset
|
54 \function{register_error()}. |
|
12260
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
55 |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
56 In case a search function cannot find a given encoding, it should |
|
12274
559b25a79032
Make sure the \declaremodule uses the right name for the module!
Fred Drake <fdrake@acm.org>
parents:
12260
diff
changeset
|
57 return \code{None}. |
|
12260
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
58 \end{funcdesc} |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
59 |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
60 \begin{funcdesc}{lookup}{encoding} |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
61 Looks up a codec tuple in the Python codec registry and returns the |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
62 function tuple as defined above. |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
63 |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
64 Encodings are first looked up in the registry's cache. If not found, |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
65 the list of registered search functions is scanned. If no codecs tuple |
|
12274
559b25a79032
Make sure the \declaremodule uses the right name for the module!
Fred Drake <fdrake@acm.org>
parents:
12260
diff
changeset
|
66 is found, a \exception{LookupError} is raised. Otherwise, the codecs |
|
559b25a79032
Make sure the \declaremodule uses the right name for the module!
Fred Drake <fdrake@acm.org>
parents:
12260
diff
changeset
|
67 tuple is stored in the cache and returned to the caller. |
|
12260
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
68 \end{funcdesc} |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
69 |
| 23112 | 70 To simplify access to the various codecs, the module provides these |
|
19982
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
71 additional functions which use \function{lookup()} for the codec |
|
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
72 lookup: |
|
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
73 |
|
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
74 \begin{funcdesc}{getencoder}{encoding} |
| 37885 | 75 Look up the codec for the given encoding and return its encoder |
|
19982
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
76 function. |
|
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
77 |
|
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
78 Raises a \exception{LookupError} in case the encoding cannot be found. |
|
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
79 \end{funcdesc} |
|
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
80 |
|
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
81 \begin{funcdesc}{getdecoder}{encoding} |
| 37885 | 82 Look up the codec for the given encoding and return its decoder |
|
19982
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
83 function. |
|
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
84 |
|
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
85 Raises a \exception{LookupError} in case the encoding cannot be found. |
|
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
86 \end{funcdesc} |
|
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
87 |
|
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
88 \begin{funcdesc}{getreader}{encoding} |
| 37885 | 89 Look up the codec for the given encoding and return its StreamReader |
|
19982
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
90 class or factory function. |
|
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
91 |
|
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
92 Raises a \exception{LookupError} in case the encoding cannot be found. |
|
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
93 \end{funcdesc} |
|
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
94 |
|
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
95 \begin{funcdesc}{getwriter}{encoding} |
| 37885 | 96 Look up the codec for the given encoding and return its StreamWriter |
|
19982
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
97 class or factory function. |
|
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
98 |
|
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
99 Raises a \exception{LookupError} in case the encoding cannot be found. |
|
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
100 \end{funcdesc} |
|
bf4b1b08a2c6
Docs and News item for the codecs.py additions.
Marc-André Lemburg <mal@egenix.com>
parents:
16127
diff
changeset
|
101 |
|
25091
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
102 \begin{funcdesc}{register_error}{name, error_handler} |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
103 Register the error handling function \var{error_handler} under the |
|
25172
5a17f0978326
Fix typo. Close SF Bug 606354.
Raymond Hettinger <python@rcn.com>
parents:
25091
diff
changeset
|
104 name \var{name}. \var{error_handler} will be called during encoding |
|
25091
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
105 and decoding in case of an error, when \var{name} is specified as the |
|
27555
c267f28724dd
Change the treatment of positions returned by PEP293
Walter Dörwald <walter@livinglogic.de>
parents:
26943
diff
changeset
|
106 errors parameter. |
|
c267f28724dd
Change the treatment of positions returned by PEP293
Walter Dörwald <walter@livinglogic.de>
parents:
26943
diff
changeset
|
107 |
|
c267f28724dd
Change the treatment of positions returned by PEP293
Walter Dörwald <walter@livinglogic.de>
parents:
26943
diff
changeset
|
108 For encoding \var{error_handler} will be called with a |
|
c267f28724dd
Change the treatment of positions returned by PEP293
Walter Dörwald <walter@livinglogic.de>
parents:
26943
diff
changeset
|
109 \exception{UnicodeEncodeError} instance, which contains information about |
|
c267f28724dd
Change the treatment of positions returned by PEP293
Walter Dörwald <walter@livinglogic.de>
parents:
26943
diff
changeset
|
110 the location of the error. The error handler must either raise this or |
|
c267f28724dd
Change the treatment of positions returned by PEP293
Walter Dörwald <walter@livinglogic.de>
parents:
26943
diff
changeset
|
111 a different exception or return a tuple with a replacement for the |
|
c267f28724dd
Change the treatment of positions returned by PEP293
Walter Dörwald <walter@livinglogic.de>
parents:
26943
diff
changeset
|
112 unencodable part of the input and a position where encoding should |
|
c267f28724dd
Change the treatment of positions returned by PEP293
Walter Dörwald <walter@livinglogic.de>
parents:
26943
diff
changeset
|
113 continue. The encoder will encode the replacement and continue encoding |
|
c267f28724dd
Change the treatment of positions returned by PEP293
Walter Dörwald <walter@livinglogic.de>
parents:
26943
diff
changeset
|
114 the original input at the specified position. Negative position values |
|
c267f28724dd
Change the treatment of positions returned by PEP293
Walter Dörwald <walter@livinglogic.de>
parents:
26943
diff
changeset
|
115 will be treated as being relative to the end of the input string. If the |
|
c267f28724dd
Change the treatment of positions returned by PEP293
Walter Dörwald <walter@livinglogic.de>
parents:
26943
diff
changeset
|
116 resulting position is out of bound an IndexError will be raised. |
|
c267f28724dd
Change the treatment of positions returned by PEP293
Walter Dörwald <walter@livinglogic.de>
parents:
26943
diff
changeset
|
117 |
|
c267f28724dd
Change the treatment of positions returned by PEP293
Walter Dörwald <walter@livinglogic.de>
parents:
26943
diff
changeset
|
118 Decoding and translating works similar, except \exception{UnicodeDecodeError} |
|
c267f28724dd
Change the treatment of positions returned by PEP293
Walter Dörwald <walter@livinglogic.de>
parents:
26943
diff
changeset
|
119 or \exception{UnicodeTranslateError} will be passed to the handler and |
|
c267f28724dd
Change the treatment of positions returned by PEP293
Walter Dörwald <walter@livinglogic.de>
parents:
26943
diff
changeset
|
120 that the replacement from the error handler will be put into the output |
|
c267f28724dd
Change the treatment of positions returned by PEP293
Walter Dörwald <walter@livinglogic.de>
parents:
26943
diff
changeset
|
121 directly. |
|
25091
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
122 \end{funcdesc} |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
123 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
124 \begin{funcdesc}{lookup_error}{name} |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
125 Return the error handler previously register under the name \var{name}. |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
126 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
127 Raises a \exception{LookupError} in case the handler cannot be found. |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
128 \end{funcdesc} |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
129 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
130 \begin{funcdesc}{strict_errors}{exception} |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
131 Implements the \code{strict} error handling. |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
132 \end{funcdesc} |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
133 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
134 \begin{funcdesc}{replace_errors}{exception} |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
135 Implements the \code{replace} error handling. |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
136 \end{funcdesc} |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
137 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
138 \begin{funcdesc}{ignore_errors}{exception} |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
139 Implements the \code{ignore} error handling. |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
140 \end{funcdesc} |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
141 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
142 \begin{funcdesc}{xmlcharrefreplace_errors_errors}{exception} |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
143 Implements the \code{xmlcharrefreplace} error handling. |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
144 \end{funcdesc} |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
145 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
146 \begin{funcdesc}{backslashreplace_errors_errors}{exception} |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
147 Implements the \code{backslashreplace} error handling. |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
148 \end{funcdesc} |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
23658
diff
changeset
|
149 |
|
25989
611af79c0e89
Move introductory sentence to where it belongs.
Walter Dörwald <walter@livinglogic.de>
parents:
25172
diff
changeset
|
150 To simplify working with encoded files or stream, the module |
|
611af79c0e89
Move introductory sentence to where it belongs.
Walter Dörwald <walter@livinglogic.de>
parents:
25172
diff
changeset
|
151 also defines these utility functions: |
|
611af79c0e89
Move introductory sentence to where it belongs.
Walter Dörwald <walter@livinglogic.de>
parents:
25172
diff
changeset
|
152 |
|
13696
bb364d6f9f69
Fix small typos and markup consistency nits.
Fred Drake <fdrake@acm.org>
parents:
12274
diff
changeset
|
153 \begin{funcdesc}{open}{filename, mode\optional{, encoding\optional{, |
|
bb364d6f9f69
Fix small typos and markup consistency nits.
Fred Drake <fdrake@acm.org>
parents:
12274
diff
changeset
|
154 errors\optional{, buffering}}}} |
|
12260
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
155 Open an encoded file using the given \var{mode} and return |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
156 a wrapped version providing transparent encoding/decoding. |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
157 |
|
20580
376ee174ecd0
Use the \note and \warning macros where appropriate.
Fred Drake <fdrake@acm.org>
parents:
19982
diff
changeset
|
158 \note{The wrapped version will only accept the object format |
|
13696
bb364d6f9f69
Fix small typos and markup consistency nits.
Fred Drake <fdrake@acm.org>
parents:
12274
diff
changeset
|
159 defined by the codecs, i.e.\ Unicode objects for most built-in |
|
bb364d6f9f69
Fix small typos and markup consistency nits.
Fred Drake <fdrake@acm.org>
parents:
12274
diff
changeset
|
160 codecs. Output is also codec-dependent and will usually be Unicode as |
|
20580
376ee174ecd0
Use the \note and \warning macros where appropriate.
Fred Drake <fdrake@acm.org>
parents:
19982
diff
changeset
|
161 well.} |
|
12260
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
162 |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
163 \var{encoding} specifies the encoding which is to be used for the |
|
30505
f4a01c405a44
Fix doubled word errors.
Raymond Hettinger <python@rcn.com>
parents:
30273
diff
changeset
|
164 file. |
|
12260
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
165 |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
166 \var{errors} may be given to define the error handling. It defaults |
|
13696
bb364d6f9f69
Fix small typos and markup consistency nits.
Fred Drake <fdrake@acm.org>
parents:
12274
diff
changeset
|
167 to \code{'strict'} which causes a \exception{ValueError} to be raised |
|
bb364d6f9f69
Fix small typos and markup consistency nits.
Fred Drake <fdrake@acm.org>
parents:
12274
diff
changeset
|
168 in case an encoding error occurs. |
|
12260
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
169 |
|
12274
559b25a79032
Make sure the \declaremodule uses the right name for the module!
Fred Drake <fdrake@acm.org>
parents:
12260
diff
changeset
|
170 \var{buffering} has the same meaning as for the built-in |
|
559b25a79032
Make sure the \declaremodule uses the right name for the module!
Fred Drake <fdrake@acm.org>
parents:
12260
diff
changeset
|
171 \function{open()} function. It defaults to line buffered. |
|
12260
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
172 \end{funcdesc} |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
173 |
|
13696
bb364d6f9f69
Fix small typos and markup consistency nits.
Fred Drake <fdrake@acm.org>
parents:
12274
diff
changeset
|
174 \begin{funcdesc}{EncodedFile}{file, input\optional{, |
|
bb364d6f9f69
Fix small typos and markup consistency nits.
Fred Drake <fdrake@acm.org>
parents:
12274
diff
changeset
|
175 output\optional{, errors}}} |
|
12260
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
176 Return a wrapped version of file which provides transparent |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
177 encoding translation. |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
178 |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
179 Strings written to the wrapped file are interpreted according to the |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
180 given \var{input} encoding and then written to the original file as |
|
13696
bb364d6f9f69
Fix small typos and markup consistency nits.
Fred Drake <fdrake@acm.org>
parents:
12274
diff
changeset
|
181 strings using the \var{output} encoding. The intermediate encoding will |
|
12260
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
182 usually be Unicode but depends on the specified codecs. |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
183 |
|
13696
bb364d6f9f69
Fix small typos and markup consistency nits.
Fred Drake <fdrake@acm.org>
parents:
12274
diff
changeset
|
184 If \var{output} is not given, it defaults to \var{input}. |
|
12260
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
185 |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
186 \var{errors} may be given to define the error handling. It defaults to |
|
13696
bb364d6f9f69
Fix small typos and markup consistency nits.
Fred Drake <fdrake@acm.org>
parents:
12274
diff
changeset
|
187 \code{'strict'}, which causes \exception{ValueError} to be raised in case |
|
12260
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
188 an encoding error occurs. |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
189 \end{funcdesc} |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
190 |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
191 The module also provides the following constants which are useful |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
192 for reading and writing to platform dependent files: |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
193 |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
194 \begin{datadesc}{BOM} |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
195 \dataline{BOM_BE} |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
196 \dataline{BOM_LE} |
|
23658
94aa4eb9bb7d
Add constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE,
Walter Dörwald <walter@livinglogic.de>
parents:
23112
diff
changeset
|
197 \dataline{BOM_UTF8} |
|
94aa4eb9bb7d
Add constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE,
Walter Dörwald <walter@livinglogic.de>
parents:
23112
diff
changeset
|
198 \dataline{BOM_UTF16} |
|
94aa4eb9bb7d
Add constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE,
Walter Dörwald <walter@livinglogic.de>
parents:
23112
diff
changeset
|
199 \dataline{BOM_UTF16_BE} |
|
94aa4eb9bb7d
Add constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE,
Walter Dörwald <walter@livinglogic.de>
parents:
23112
diff
changeset
|
200 \dataline{BOM_UTF16_LE} |
|
94aa4eb9bb7d
Add constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE,
Walter Dörwald <walter@livinglogic.de>
parents:
23112
diff
changeset
|
201 \dataline{BOM_UTF32} |
|
94aa4eb9bb7d
Add constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE,
Walter Dörwald <walter@livinglogic.de>
parents:
23112
diff
changeset
|
202 \dataline{BOM_UTF32_BE} |
|
94aa4eb9bb7d
Add constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE,
Walter Dörwald <walter@livinglogic.de>
parents:
23112
diff
changeset
|
203 \dataline{BOM_UTF32_LE} |
|
94aa4eb9bb7d
Add constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE,
Walter Dörwald <walter@livinglogic.de>
parents:
23112
diff
changeset
|
204 These constants define various encodings of the Unicode byte order mark |
|
94aa4eb9bb7d
Add constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE,
Walter Dörwald <walter@livinglogic.de>
parents:
23112
diff
changeset
|
205 (BOM) used in UTF-16 and UTF-32 data streams to indicate the byte order |
|
94aa4eb9bb7d
Add constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE,
Walter Dörwald <walter@livinglogic.de>
parents:
23112
diff
changeset
|
206 used in the stream or file and in UTF-8 as a Unicode signature. |
|
94aa4eb9bb7d
Add constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE,
Walter Dörwald <walter@livinglogic.de>
parents:
23112
diff
changeset
|
207 \constant{BOM_UTF16} is either \constant{BOM_UTF16_BE} or |
|
94aa4eb9bb7d
Add constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE,
Walter Dörwald <walter@livinglogic.de>
parents:
23112
diff
changeset
|
208 \constant{BOM_UTF16_LE} depending on the platform's native byte order, |
|
94aa4eb9bb7d
Add constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE,
Walter Dörwald <walter@livinglogic.de>
parents:
23112
diff
changeset
|
209 \constant{BOM} is an alias for \constant{BOM_UTF16}, \constant{BOM_LE} |
|
94aa4eb9bb7d
Add constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE,
Walter Dörwald <walter@livinglogic.de>
parents:
23112
diff
changeset
|
210 for \constant{BOM_UTF16_LE} and \constant{BOM_BE} for \constant{BOM_UTF16_BE}. |
|
94aa4eb9bb7d
Add constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE,
Walter Dörwald <walter@livinglogic.de>
parents:
23112
diff
changeset
|
211 The others represent the BOM in UTF-8 and UTF-32 encodings. |
|
12260
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
212 \end{datadesc} |
|
8c0f863ba50c
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
213 |
|
16127
6f1fd8500398
Added link to the "Python Codecs" project at SourceForge.
Fred Drake <fdrake@acm.org>
parents:
15186
diff
changeset
|
214 |
| 35952 | 215 \subsection{Codec Base Classes \label{codec-base-classes}} |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
216 |
| 35740 | 217 The \module{codecs} module defines a set of base classes which define the |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
218 interface and can also be used to easily write you own codecs for use |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
219 in Python. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
220 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
221 Each codec has to define four interfaces to make it usable as codec in |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
222 Python: stateless encoder, stateless decoder, stream reader and stream |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
223 writer. The stream reader and writers typically reuse the stateless |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
224 encoder/decoder to implement the file protocols. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
225 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
226 The \class{Codec} class defines the interface for stateless |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
227 encoders/decoders. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
228 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
229 To simplify and standardize error handling, the \method{encode()} and |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
230 \method{decode()} methods may implement different error handling |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
231 schemes by providing the \var{errors} string argument. The following |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
232 string values are defined and implemented by all standard Python |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
233 codecs: |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
234 |
|
16127
6f1fd8500398
Added link to the "Python Codecs" project at SourceForge.
Fred Drake <fdrake@acm.org>
parents:
15186
diff
changeset
|
235 \begin{tableii}{l|l}{code}{Value}{Meaning} |
|
26099
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
236 \lineii{'strict'}{Raise \exception{UnicodeError} (or a subclass); |
|
16127
6f1fd8500398
Added link to the "Python Codecs" project at SourceForge.
Fred Drake <fdrake@acm.org>
parents:
15186
diff
changeset
|
237 this is the default.} |
|
6f1fd8500398
Added link to the "Python Codecs" project at SourceForge.
Fred Drake <fdrake@acm.org>
parents:
15186
diff
changeset
|
238 \lineii{'ignore'}{Ignore the character and continue with the next.} |
|
6f1fd8500398
Added link to the "Python Codecs" project at SourceForge.
Fred Drake <fdrake@acm.org>
parents:
15186
diff
changeset
|
239 \lineii{'replace'}{Replace with a suitable replacement character; |
|
6f1fd8500398
Added link to the "Python Codecs" project at SourceForge.
Fred Drake <fdrake@acm.org>
parents:
15186
diff
changeset
|
240 Python will use the official U+FFFD REPLACEMENT |
|
26099
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
241 CHARACTER for the built-in Unicode codecs on |
|
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
242 decoding and '?' on encoding.} |
|
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
243 \lineii{'xmlcharrefreplace'}{Replace with the appropriate XML |
|
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
244 character reference (only for encoding).} |
|
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
245 \lineii{'backslashreplace'}{Replace with backslashed escape sequences |
|
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
246 (only for encoding).} |
|
16127
6f1fd8500398
Added link to the "Python Codecs" project at SourceForge.
Fred Drake <fdrake@acm.org>
parents:
15186
diff
changeset
|
247 \end{tableii} |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
248 |
|
26099
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
249 The set of allowed values can be extended via \method{register_error}. |
|
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
250 |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
251 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
252 \subsubsection{Codec Objects \label{codec-objects}} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
253 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
254 The \class{Codec} class defines these methods which also define the |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
255 function interfaces of the stateless encoder and decoder: |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
256 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
257 \begin{methoddesc}{encode}{input\optional{, errors}} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
258 Encodes the object \var{input} and returns a tuple (output object, |
|
23087
09db3f5d0bd0
added small clarification to the descriptions of encode() and decode()
Skip Montanaro <skip@pobox.com>
parents:
20580
diff
changeset
|
259 length consumed). While codecs are not restricted to use with Unicode, in |
|
09db3f5d0bd0
added small clarification to the descriptions of encode() and decode()
Skip Montanaro <skip@pobox.com>
parents:
20580
diff
changeset
|
260 a Unicode context, encoding converts a Unicode object to a plain string |
|
09db3f5d0bd0
added small clarification to the descriptions of encode() and decode()
Skip Montanaro <skip@pobox.com>
parents:
20580
diff
changeset
|
261 using a particular character set encoding (e.g., \code{cp1252} or |
|
09db3f5d0bd0
added small clarification to the descriptions of encode() and decode()
Skip Montanaro <skip@pobox.com>
parents:
20580
diff
changeset
|
262 \code{iso-8859-1}). |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
263 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
264 \var{errors} defines the error handling to apply. It defaults to |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
265 \code{'strict'} handling. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
266 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
267 The method may not store state in the \class{Codec} instance. Use |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
268 \class{StreamCodec} for codecs which have to keep state in order to |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
269 make encoding/decoding efficient. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
270 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
271 The encoder must be able to handle zero length input and return an |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
272 empty object of the output object type in this situation. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
273 \end{methoddesc} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
274 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
275 \begin{methoddesc}{decode}{input\optional{, errors}} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
276 Decodes the object \var{input} and returns a tuple (output object, |
|
23087
09db3f5d0bd0
added small clarification to the descriptions of encode() and decode()
Skip Montanaro <skip@pobox.com>
parents:
20580
diff
changeset
|
277 length consumed). In a Unicode context, decoding converts a plain string |
|
09db3f5d0bd0
added small clarification to the descriptions of encode() and decode()
Skip Montanaro <skip@pobox.com>
parents:
20580
diff
changeset
|
278 encoded using a particular character set encoding to a Unicode object. |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
279 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
280 \var{input} must be an object which provides the \code{bf_getreadbuf} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
281 buffer slot. Python strings, buffer objects and memory mapped files |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
282 are examples of objects providing this slot. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
283 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
284 \var{errors} defines the error handling to apply. It defaults to |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
285 \code{'strict'} handling. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
286 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
287 The method may not store state in the \class{Codec} instance. Use |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
288 \class{StreamCodec} for codecs which have to keep state in order to |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
289 make encoding/decoding efficient. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
290 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
291 The decoder must be able to handle zero length input and return an |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
292 empty object of the output object type in this situation. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
293 \end{methoddesc} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
294 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
295 The \class{StreamWriter} and \class{StreamReader} classes provide |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
296 generic working interfaces which can be used to implement new |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
297 encodings submodules very easily. See \module{encodings.utf_8} for an |
| 37889 | 298 example of how this is done. |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
299 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
300 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
301 \subsubsection{StreamWriter Objects \label{stream-writer-objects}} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
302 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
303 The \class{StreamWriter} class is a subclass of \class{Codec} and |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
304 defines the following methods which every stream writer must define in |
| 37889 | 305 order to be compatible with the Python codec registry. |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
306 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
307 \begin{classdesc}{StreamWriter}{stream\optional{, errors}} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
308 Constructor for a \class{StreamWriter} instance. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
309 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
310 All stream writers must provide this constructor interface. They are |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
311 free to add additional keyword arguments, but only the ones defined |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
312 here are used by the Python codec registry. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
313 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
314 \var{stream} must be a file-like object open for writing (binary) |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
315 data. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
316 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
317 The \class{StreamWriter} may implement different error handling |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
318 schemes by providing the \var{errors} keyword argument. These |
|
26099
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
319 parameters are predefined: |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
320 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
321 \begin{itemize} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
322 \item \code{'strict'} Raise \exception{ValueError} (or a subclass); |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
323 this is the default. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
324 \item \code{'ignore'} Ignore the character and continue with the next. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
325 \item \code{'replace'} Replace with a suitable replacement character |
|
26099
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
326 \item \code{'xmlcharrefreplace'} Replace with the appropriate XML |
|
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
327 character reference |
|
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
328 \item \code{'backslashreplace'} Replace with backslashed escape sequences. |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
329 \end{itemize} |
|
26099
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
330 |
|
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
331 The \var{errors} argument will be assigned to an attribute of the |
|
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
332 same name. Assigning to this attribute makes it possible to switch |
|
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
333 between different error handling strategies during the lifetime |
|
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
334 of the \class{StreamWriter} object. |
|
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
335 |
|
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
336 The set of allowed values for the \var{errors} argument can |
|
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
337 be extended with \function{register_error()}. |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
338 \end{classdesc} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
339 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
340 \begin{methoddesc}{write}{object} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
341 Writes the object's contents encoded to the stream. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
342 \end{methoddesc} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
343 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
344 \begin{methoddesc}{writelines}{list} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
345 Writes the concatenated list of strings to the stream (possibly by |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
346 reusing the \method{write()} method). |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
347 \end{methoddesc} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
348 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
349 \begin{methoddesc}{reset}{} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
350 Flushes and resets the codec buffers used for keeping state. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
351 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
352 Calling this method should ensure that the data on the output is put |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
353 into a clean state, that allows appending of new fresh data without |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
354 having to rescan the whole stream to recover state. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
355 \end{methoddesc} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
356 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
357 In addition to the above methods, the \class{StreamWriter} must also |
| 37889 | 358 inherit all other methods and attributes from the underlying stream. |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
359 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
360 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
361 \subsubsection{StreamReader Objects \label{stream-reader-objects}} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
362 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
363 The \class{StreamReader} class is a subclass of \class{Codec} and |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
364 defines the following methods which every stream reader must define in |
| 37889 | 365 order to be compatible with the Python codec registry. |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
366 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
367 \begin{classdesc}{StreamReader}{stream\optional{, errors}} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
368 Constructor for a \class{StreamReader} instance. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
369 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
370 All stream readers must provide this constructor interface. They are |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
371 free to add additional keyword arguments, but only the ones defined |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
372 here are used by the Python codec registry. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
373 |
| 37889 | 374 \var{stream} must be a file-like object open for reading binary |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
375 data. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
376 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
377 The \class{StreamReader} may implement different error handling |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
378 schemes by providing the \var{errors} keyword argument. These |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
379 parameters are defined: |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
380 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
381 \begin{itemize} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
382 \item \code{'strict'} Raise \exception{ValueError} (or a subclass); |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
383 this is the default. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
384 \item \code{'ignore'} Ignore the character and continue with the next. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
385 \item \code{'replace'} Replace with a suitable replacement character. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
386 \end{itemize} |
|
26099
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
387 |
|
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
388 The \var{errors} argument will be assigned to an attribute of the |
|
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
389 same name. Assigning to this attribute makes it possible to switch |
|
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
390 between different error handling strategies during the lifetime |
|
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
391 of the \class{StreamReader} object. |
|
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
392 |
|
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
393 The set of allowed values for the \var{errors} argument can |
|
135f08b73bd5
Add documentation for the PEP 293 functionality:
Walter Dörwald <walter@livinglogic.de>
parents:
25989
diff
changeset
|
394 be extended with \function{register_error()}. |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
395 \end{classdesc} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
396 |
|
35416
4896f8334bff
Return complete lines from codec stream readers
Martin v. Löwis <martin@v.loewis.de>
parents:
34296
diff
changeset
|
397 \begin{methoddesc}{read}{\optional{size\optional{, chars, \optional{firstline}}}} |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
398 Decodes data from the stream and returns the resulting object. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
399 |
|
33428
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32727
diff
changeset
|
400 \var{chars} indicates the number of characters to read from the |
| 33437 | 401 stream. \function{read()} will never return more than \var{chars} |
|
33428
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32727
diff
changeset
|
402 characters, but it might return less, if there are not enough |
|
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32727
diff
changeset
|
403 characters available. |
|
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32727
diff
changeset
|
404 |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
405 \var{size} indicates the approximate maximum number of bytes to read |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
406 from the stream for decoding purposes. The decoder can modify this |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
407 setting as appropriate. The default value -1 indicates to read and |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
408 decode as much as possible. \var{size} is intended to prevent having |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
409 to decode huge files in one step. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
410 |
|
35416
4896f8334bff
Return complete lines from codec stream readers
Martin v. Löwis <martin@v.loewis.de>
parents:
34296
diff
changeset
|
411 \var{firstline} indicates that it would be sufficient to only return |
|
4896f8334bff
Return complete lines from codec stream readers
Martin v. Löwis <martin@v.loewis.de>
parents:
34296
diff
changeset
|
412 the first line, if there are decoding errors on later lines. |
|
4896f8334bff
Return complete lines from codec stream readers
Martin v. Löwis <martin@v.loewis.de>
parents:
34296
diff
changeset
|
413 |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
414 The method should use a greedy read strategy meaning that it should |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
415 read as much data as is allowed within the definition of the encoding |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
416 and the given size, e.g. if optional encoding endings or state |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
417 markers are available on the stream, these should be read too. |
|
33428
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32727
diff
changeset
|
418 |
|
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32727
diff
changeset
|
419 \versionchanged[\var{chars} argument added]{2.4} |
|
35416
4896f8334bff
Return complete lines from codec stream readers
Martin v. Löwis <martin@v.loewis.de>
parents:
34296
diff
changeset
|
420 \versionchanged[\var{firstline} argument added]{2.4.2} |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
421 \end{methoddesc} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
422 |
|
33428
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32727
diff
changeset
|
423 \begin{methoddesc}{readline}{\optional{size\optional{, keepends}}} |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
424 Read one line from the input stream and return the |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
425 decoded data. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
426 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
427 \var{size}, if given, is passed as size argument to the stream's |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
428 \method{readline()} method. |
|
33428
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32727
diff
changeset
|
429 |
| 37889 | 430 If \var{keepends} is false line-endings will be stripped from the |
|
33428
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32727
diff
changeset
|
431 lines returned. |
|
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32727
diff
changeset
|
432 |
|
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32727
diff
changeset
|
433 \versionchanged[\var{keepends} argument added]{2.4} |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
434 \end{methoddesc} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
435 |
|
33428
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32727
diff
changeset
|
436 \begin{methoddesc}{readlines}{\optional{sizehint\optional{, keepends}}} |
| 37889 | 437 Read all lines available on the input stream and return them as a list |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
438 of lines. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
439 |
| 37889 | 440 Line-endings are implemented using the codec's decoder method and are |
|
33428
57478a13fbf6
SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
Walter Dörwald <walter@livinglogic.de>
parents:
32727
diff
changeset
|
441 included in the list entries if \var{keepends} is true. |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
442 |
| 37889 | 443 \var{sizehint}, if given, is passed as the \var{size} argument to the |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
444 stream's \method{read()} method. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
445 \end{methoddesc} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
446 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
447 \begin{methoddesc}{reset}{} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
448 Resets the codec buffers used for keeping state. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
449 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
450 Note that no stream repositioning should take place. This method is |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
451 primarily intended to be able to recover from decoding errors. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
452 \end{methoddesc} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
453 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
454 In addition to the above methods, the \class{StreamReader} must also |
| 37889 | 455 inherit all other methods and attributes from the underlying stream. |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
456 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
457 The next two base classes are included for convenience. They are not |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
458 needed by the codec registry, but may provide useful in practice. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
459 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
460 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
461 \subsubsection{StreamReaderWriter Objects \label{stream-reader-writer}} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
462 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
463 The \class{StreamReaderWriter} allows wrapping streams which work in |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
464 both read and write modes. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
465 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
466 The design is such that one can use the factory functions returned by |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
467 the \function{lookup()} function to construct the instance. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
468 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
469 \begin{classdesc}{StreamReaderWriter}{stream, Reader, Writer, errors} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
470 Creates a \class{StreamReaderWriter} instance. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
471 \var{stream} must be a file-like object. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
472 \var{Reader} and \var{Writer} must be factory functions or classes |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
473 providing the \class{StreamReader} and \class{StreamWriter} interface |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
474 resp. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
475 Error handling is done in the same way as defined for the |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
476 stream readers and writers. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
477 \end{classdesc} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
478 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
479 \class{StreamReaderWriter} instances define the combined interfaces of |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
480 \class{StreamReader} and \class{StreamWriter} classes. They inherit |
| 37889 | 481 all other methods and attributes from the underlying stream. |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
482 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
483 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
484 \subsubsection{StreamRecoder Objects \label{stream-recoder-objects}} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
485 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
486 The \class{StreamRecoder} provide a frontend - backend view of |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
487 encoding data which is sometimes useful when dealing with different |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
488 encoding environments. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
489 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
490 The design is such that one can use the factory functions returned by |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
491 the \function{lookup()} function to construct the instance. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
492 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
493 \begin{classdesc}{StreamRecoder}{stream, encode, decode, |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
494 Reader, Writer, errors} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
495 Creates a \class{StreamRecoder} instance which implements a two-way |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
496 conversion: \var{encode} and \var{decode} work on the frontend (the |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
497 input to \method{read()} and output of \method{write()}) while |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
498 \var{Reader} and \var{Writer} work on the backend (reading and |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
499 writing to the stream). |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
500 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
501 You can use these objects to do transparent direct recodings from |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
502 e.g.\ Latin-1 to UTF-8 and back. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
503 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
504 \var{stream} must be a file-like object. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
505 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
506 \var{encode}, \var{decode} must adhere to the \class{Codec} |
| 37889 | 507 interface. \var{Reader}, \var{Writer} must be factory functions or |
|
30134
523c3d61dbdd
SF patch#786531 'the the' typo. Contributed by George Yoshida
Raymond Hettinger <python@rcn.com>
parents:
29894
diff
changeset
|
508 classes providing objects of the \class{StreamReader} and |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
509 \class{StreamWriter} interface respectively. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
510 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
511 \var{encode} and \var{decode} are needed for the frontend |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
512 translation, \var{Reader} and \var{Writer} for the backend |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
513 translation. The intermediate format used is determined by the two |
| 37889 | 514 sets of codecs, e.g. the Unicode codecs will use Unicode as the |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
515 intermediate encoding. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
516 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
517 Error handling is done in the same way as defined for the |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
518 stream readers and writers. |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
519 \end{classdesc} |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
520 |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
521 \class{StreamRecoder} instances define the combined interfaces of |
|
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
522 \class{StreamReader} and \class{StreamWriter} classes. They inherit |
| 37889 | 523 all other methods and attributes from the underlying stream. |
|
15186
b2892cbc63db
Marc-Andre Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
13696
diff
changeset
|
524 |
|
32458
b73ab309ada7
link to the codecs page from the "".encode() description.
Skip Montanaro <skip@pobox.com>
parents:
31687
diff
changeset
|
525 \subsection{Standard Encodings\label{standard-encodings}} |
|
26943
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
526 |
| 37889 | 527 Python comes with a number of codecs built-in, either implemented as C |
| 528 functions or with dictionaries as mapping tables. The following table | |
|
26943
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
529 lists the codecs by name, together with a few common aliases, and the |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
530 languages for which the encoding is likely used. Neither the list of |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
531 aliases nor the list of languages is meant to be exhaustive. Notice |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
532 that spelling alternatives that only differ in case or use a hyphen |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
533 instead of an underscore are also valid aliases. |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
534 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
535 Many of the character sets support the same languages. They vary in |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
536 individual characters (e.g. whether the EURO SIGN is supported or |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
537 not), and in the assignment of characters to code positions. For the |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
538 European languages in particular, the following variants typically |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
539 exist: |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
540 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
541 \begin{itemize} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
542 \item an ISO 8859 codeset |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
543 \item a Microsoft Windows code page, which is typically derived from |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
544 a 8859 codeset, but replaces control characters with additional |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
545 graphic characters |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
546 \item an IBM EBCDIC code page |
|
28906
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
547 \item an IBM PC code page, which is \ASCII{} compatible |
|
26943
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
548 \end{itemize} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
549 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
550 \begin{longtableiii}{l|l|l}{textrm}{Codec}{Aliases}{Languages} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
551 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
552 \lineiii{ascii} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
553 {646, us-ascii} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
554 {English} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
555 |
|
31386
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
556 \lineiii{big5} |
|
32722
4d43b0abc22a
Change CJK encoding aliases to their most popular variation of
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32462
diff
changeset
|
557 {big5-tw, csbig5} |
|
31386
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
558 {Traditional Chinese} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
559 |
|
32727
69dadc2ca14d
Bring CJKCodecs 1.1 into trunk. This completely reorganizes source
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32722
diff
changeset
|
560 \lineiii{big5hkscs} |
|
69dadc2ca14d
Bring CJKCodecs 1.1 into trunk. This completely reorganizes source
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32722
diff
changeset
|
561 {big5-hkscs, hkscs} |
|
69dadc2ca14d
Bring CJKCodecs 1.1 into trunk. This completely reorganizes source
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32722
diff
changeset
|
562 {Traditional Chinese} |
|
69dadc2ca14d
Bring CJKCodecs 1.1 into trunk. This completely reorganizes source
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32722
diff
changeset
|
563 |
|
26943
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
564 \lineiii{cp037} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
565 {IBM037, IBM039} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
566 {English} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
567 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
568 \lineiii{cp424} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
569 {EBCDIC-CP-HE, IBM424} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
570 {Hebrew} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
571 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
572 \lineiii{cp437} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
573 {437, IBM437} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
574 {English} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
575 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
576 \lineiii{cp500} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
577 {EBCDIC-CP-BE, EBCDIC-CP-CH, IBM500} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
578 {Western Europe} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
579 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
580 \lineiii{cp737} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
581 {} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
582 {Greek} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
583 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
584 \lineiii{cp775} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
585 {IBM775} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
586 {Baltic languages} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
587 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
588 \lineiii{cp850} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
589 {850, IBM850} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
590 {Western Europe} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
591 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
592 \lineiii{cp852} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
593 {852, IBM852} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
594 {Central and Eastern Europe} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
595 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
596 \lineiii{cp855} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
597 {855, IBM855} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
598 {Bulgarian, Byelorussian, Macedonian, Russian, Serbian} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
599 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
600 \lineiii{cp856} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
601 {} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
602 {Hebrew} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
603 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
604 \lineiii{cp857} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
605 {857, IBM857} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
606 {Turkish} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
607 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
608 \lineiii{cp860} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
609 {860, IBM860} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
610 {Portuguese} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
611 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
612 \lineiii{cp861} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
613 {861, CP-IS, IBM861} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
614 {Icelandic} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
615 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
616 \lineiii{cp862} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
617 {862, IBM862} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
618 {Hebrew} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
619 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
620 \lineiii{cp863} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
621 {863, IBM863} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
622 {Canadian} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
623 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
624 \lineiii{cp864} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
625 {IBM864} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
626 {Arabic} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
627 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
628 \lineiii{cp865} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
629 {865, IBM865} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
630 {Danish, Norwegian} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
631 |
| 32462 | 632 \lineiii{cp866} |
| 633 {866, IBM866} | |
| 634 {Russian} | |
| 635 | |
|
26943
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
636 \lineiii{cp869} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
637 {869, CP-GR, IBM869} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
638 {Greek} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
639 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
640 \lineiii{cp874} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
641 {} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
642 {Thai} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
643 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
644 \lineiii{cp875} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
645 {} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
646 {Greek} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
647 |
|
31386
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
648 \lineiii{cp932} |
|
32722
4d43b0abc22a
Change CJK encoding aliases to their most popular variation of
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32462
diff
changeset
|
649 {932, ms932, mskanji, ms-kanji} |
|
31386
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
650 {Japanese} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
651 |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
652 \lineiii{cp949} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
653 {949, ms949, uhc} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
654 {Korean} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
655 |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
656 \lineiii{cp950} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
657 {950, ms950} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
658 {Traditional Chinese} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
659 |
|
26943
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
660 \lineiii{cp1006} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
661 {} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
662 {Urdu} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
663 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
664 \lineiii{cp1026} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
665 {ibm1026} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
666 {Turkish} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
667 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
668 \lineiii{cp1140} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
669 {ibm1140} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
670 {Western Europe} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
671 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
672 \lineiii{cp1250} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
673 {windows-1250} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
674 {Central and Eastern Europe} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
675 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
676 \lineiii{cp1251} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
677 {windows-1251} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
678 {Bulgarian, Byelorussian, Macedonian, Russian, Serbian} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
679 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
680 \lineiii{cp1252} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
681 {windows-1252} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
682 {Western Europe} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
683 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
684 \lineiii{cp1253} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
685 {windows-1253} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
686 {Greek} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
687 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
688 \lineiii{cp1254} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
689 {windows-1254} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
690 {Turkish} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
691 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
692 \lineiii{cp1255} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
693 {windows-1255} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
694 {Hebrew} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
695 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
696 \lineiii{cp1256} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
697 {windows1256} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
698 {Arabic} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
699 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
700 \lineiii{cp1257} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
701 {windows-1257} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
702 {Baltic languages} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
703 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
704 \lineiii{cp1258} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
705 {windows-1258} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
706 {Vietnamese} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
707 |
|
31386
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
708 \lineiii{euc_jp} |
|
32722
4d43b0abc22a
Change CJK encoding aliases to their most popular variation of
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32462
diff
changeset
|
709 {eucjp, ujis, u-jis} |
|
31386
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
710 {Japanese} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
711 |
|
32727
69dadc2ca14d
Bring CJKCodecs 1.1 into trunk. This completely reorganizes source
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32722
diff
changeset
|
712 \lineiii{euc_jis_2004} |
|
69dadc2ca14d
Bring CJKCodecs 1.1 into trunk. This completely reorganizes source
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32722
diff
changeset
|
713 {jisx0213, eucjis2004} |
|
69dadc2ca14d
Bring CJKCodecs 1.1 into trunk. This completely reorganizes source
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32722
diff
changeset
|
714 {Japanese} |
|
69dadc2ca14d
Bring CJKCodecs 1.1 into trunk. This completely reorganizes source
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32722
diff
changeset
|
715 |
|
31386
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
716 \lineiii{euc_jisx0213} |
|
32727
69dadc2ca14d
Bring CJKCodecs 1.1 into trunk. This completely reorganizes source
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32722
diff
changeset
|
717 {eucjisx0213} |
|
31386
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
718 {Japanese} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
719 |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
720 \lineiii{euc_kr} |
|
32722
4d43b0abc22a
Change CJK encoding aliases to their most popular variation of
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32462
diff
changeset
|
721 {euckr, korean, ksc5601, ks_c-5601, ks_c-5601-1987, ksx1001, ks_x-1001} |
|
31386
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
722 {Korean} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
723 |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
724 \lineiii{gb2312} |
|
32722
4d43b0abc22a
Change CJK encoding aliases to their most popular variation of
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32462
diff
changeset
|
725 {chinese, csiso58gb231280, euc-cn, euccn, eucgb2312-cn, gb2312-1980, |
|
4d43b0abc22a
Change CJK encoding aliases to their most popular variation of
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32462
diff
changeset
|
726 gb2312-80, iso-ir-58} |
|
31386
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
727 {Simplified Chinese} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
728 |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
729 \lineiii{gbk} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
730 {936, cp936, ms936} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
731 {Unified Chinese} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
732 |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
733 \lineiii{gb18030} |
|
32722
4d43b0abc22a
Change CJK encoding aliases to their most popular variation of
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32462
diff
changeset
|
734 {gb18030-2000} |
|
31386
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
735 {Unified Chinese} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
736 |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
737 \lineiii{hz} |
|
32722
4d43b0abc22a
Change CJK encoding aliases to their most popular variation of
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32462
diff
changeset
|
738 {hzgb, hz-gb, hz-gb-2312} |
|
31386
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
739 {Simplified Chinese} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
740 |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
741 \lineiii{iso2022_jp} |
|
32722
4d43b0abc22a
Change CJK encoding aliases to their most popular variation of
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32462
diff
changeset
|
742 {csiso2022jp, iso2022jp, iso-2022-jp} |
|
31386
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
743 {Japanese} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
744 |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
745 \lineiii{iso2022_jp_1} |
|
32722
4d43b0abc22a
Change CJK encoding aliases to their most popular variation of
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32462
diff
changeset
|
746 {iso2022jp-1, iso-2022-jp-1} |
|
31386
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
747 {Japanese} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
748 |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
749 \lineiii{iso2022_jp_2} |
|
32722
4d43b0abc22a
Change CJK encoding aliases to their most popular variation of
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32462
diff
changeset
|
750 {iso2022jp-2, iso-2022-jp-2} |
|
31386
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
751 {Japanese, Korean, Simplified Chinese, Western Europe, Greek} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
752 |
|
32727
69dadc2ca14d
Bring CJKCodecs 1.1 into trunk. This completely reorganizes source
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32722
diff
changeset
|
753 \lineiii{iso2022_jp_2004} |
|
69dadc2ca14d
Bring CJKCodecs 1.1 into trunk. This completely reorganizes source
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32722
diff
changeset
|
754 {iso2022jp-2004, iso-2022-jp-2004} |
|
69dadc2ca14d
Bring CJKCodecs 1.1 into trunk. This completely reorganizes source
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32722
diff
changeset
|
755 {Japanese} |
|
69dadc2ca14d
Bring CJKCodecs 1.1 into trunk. This completely reorganizes source
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32722
diff
changeset
|
756 |
|
31386
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
757 \lineiii{iso2022_jp_3} |
|
32722
4d43b0abc22a
Change CJK encoding aliases to their most popular variation of
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32462
diff
changeset
|
758 {iso2022jp-3, iso-2022-jp-3} |
|
31386
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
759 {Japanese} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
760 |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
761 \lineiii{iso2022_jp_ext} |
|
32722
4d43b0abc22a
Change CJK encoding aliases to their most popular variation of
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32462
diff
changeset
|
762 {iso2022jp-ext, iso-2022-jp-ext} |
|
31386
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
763 {Japanese} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
764 |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
765 \lineiii{iso2022_kr} |
|
32722
4d43b0abc22a
Change CJK encoding aliases to their most popular variation of
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32462
diff
changeset
|
766 {csiso2022kr, iso2022kr, iso-2022-kr} |
|
31386
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
767 {Korean} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
768 |
|
26943
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
769 \lineiii{latin_1} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
770 {iso-8859-1, iso8859-1, 8859, cp819, latin, latin1, L1} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
771 {West Europe} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
772 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
773 \lineiii{iso8859_2} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
774 {iso-8859-2, latin2, L2} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
775 {Central and Eastern Europe} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
776 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
777 \lineiii{iso8859_3} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
778 {iso-8859-3, latin3, L3} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
779 {Esperanto, Maltese} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
780 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
781 \lineiii{iso8859_4} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
782 {iso-8859-4, latin4, L4} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
783 {Baltic languagues} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
784 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
785 \lineiii{iso8859_5} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
786 {iso-8859-5, cyrillic} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
787 {Bulgarian, Byelorussian, Macedonian, Russian, Serbian} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
788 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
789 \lineiii{iso8859_6} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
790 {iso-8859-6, arabic} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
791 {Arabic} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
792 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
793 \lineiii{iso8859_7} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
794 {iso-8859-7, greek, greek8} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
795 {Greek} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
796 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
797 \lineiii{iso8859_8} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
798 {iso-8859-8, hebrew} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
799 {Hebrew} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
800 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
801 \lineiii{iso8859_9} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
802 {iso-8859-9, latin5, L5} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
803 {Turkish} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
804 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
805 \lineiii{iso8859_10} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
806 {iso-8859-10, latin6, L6} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
807 {Nordic languages} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
808 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
809 \lineiii{iso8859_13} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
810 {iso-8859-13} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
811 {Baltic languages} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
812 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
813 \lineiii{iso8859_14} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
814 {iso-8859-14, latin8, L8} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
815 {Celtic languages} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
816 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
817 \lineiii{iso8859_15} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
818 {iso-8859-15} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
819 {Western Europe} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
820 |
|
31386
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
821 \lineiii{johab} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
822 {cp1361, ms1361} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
823 {Korean} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
824 |
|
26943
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
825 \lineiii{koi8_r} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
826 {} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
827 {Russian} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
828 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
829 \lineiii{koi8_u} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
830 {} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
831 {Ukrainian} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
832 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
833 \lineiii{mac_cyrillic} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
834 {maccyrillic} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
835 {Bulgarian, Byelorussian, Macedonian, Russian, Serbian} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
836 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
837 \lineiii{mac_greek} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
838 {macgreek} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
839 {Greek} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
840 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
841 \lineiii{mac_iceland} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
842 {maciceland} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
843 {Icelandic} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
844 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
845 \lineiii{mac_latin2} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
846 {maclatin2, maccentraleurope} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
847 {Central and Eastern Europe} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
848 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
849 \lineiii{mac_roman} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
850 {macroman} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
851 {Western Europe} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
852 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
853 \lineiii{mac_turkish} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
854 {macturkish} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
855 {Turkish} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
856 |
|
31687
a885e4d64ad0
Add a new unicode codec: ptcp154 (Kazakh)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31386
diff
changeset
|
857 \lineiii{ptcp154} |
|
a885e4d64ad0
Add a new unicode codec: ptcp154 (Kazakh)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31386
diff
changeset
|
858 {csptcp154, pt154, cp154, cyrillic-asian} |
|
a885e4d64ad0
Add a new unicode codec: ptcp154 (Kazakh)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31386
diff
changeset
|
859 {Kazakh} |
|
a885e4d64ad0
Add a new unicode codec: ptcp154 (Kazakh)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31386
diff
changeset
|
860 |
|
31386
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
861 \lineiii{shift_jis} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
862 {csshiftjis, shiftjis, sjis, s_jis} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
863 {Japanese} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
864 |
|
32727
69dadc2ca14d
Bring CJKCodecs 1.1 into trunk. This completely reorganizes source
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32722
diff
changeset
|
865 \lineiii{shift_jis_2004} |
|
69dadc2ca14d
Bring CJKCodecs 1.1 into trunk. This completely reorganizes source
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32722
diff
changeset
|
866 {shiftjis2004, sjis_2004, sjis2004} |
|
69dadc2ca14d
Bring CJKCodecs 1.1 into trunk. This completely reorganizes source
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32722
diff
changeset
|
867 {Japanese} |
|
69dadc2ca14d
Bring CJKCodecs 1.1 into trunk. This completely reorganizes source
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32722
diff
changeset
|
868 |
|
31386
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
869 \lineiii{shift_jisx0213} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
870 {shiftjisx0213, sjisx0213, s_jisx0213} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
871 {Japanese} |
|
887ce39f95f2
Add CJK codecs support as discussed on python-dev. (SF #873597)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
30522
diff
changeset
|
872 |
|
26943
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
873 \lineiii{utf_16} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
874 {U16, utf16} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
875 {all languages} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
876 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
877 \lineiii{utf_16_be} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
878 {UTF-16BE} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
879 {all languages (BMP only)} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
880 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
881 \lineiii{utf_16_le} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
882 {UTF-16LE} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
883 {all languages (BMP only)} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
884 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
885 \lineiii{utf_7} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
886 {U7} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
887 {all languages} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
888 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
889 \lineiii{utf_8} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
890 {U8, UTF, utf8} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
891 {all languages} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
892 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
893 \end{longtableiii} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
894 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
895 A number of codecs are specific to Python, so their codec names have |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
896 no meaning outside Python. Some of them don't convert from Unicode |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
897 strings to byte strings, but instead use the property of the Python |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
898 codecs machinery that any bijective function with one argument can be |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
899 considered as an encoding. |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
900 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
901 For the codecs listed below, the result in the ``encoding'' direction |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
902 is always a byte string. The result of the ``decoding'' direction is |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
903 listed as operand type in the table. |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
904 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
905 \begin{tableiv}{l|l|l|l}{textrm}{Codec}{Aliases}{Operand type}{Purpose} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
906 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
907 \lineiv{base64_codec} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
908 {base64, base-64} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
909 {byte string} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
910 {Convert operand to MIME base64} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
911 |
|
30522
db63cb0fc7da
Added codec for bz2 compression.
Raymond Hettinger <python@rcn.com>
parents:
30505
diff
changeset
|
912 \lineiv{bz2_codec} |
|
db63cb0fc7da
Added codec for bz2 compression.
Raymond Hettinger <python@rcn.com>
parents:
30505
diff
changeset
|
913 {bz2} |
|
db63cb0fc7da
Added codec for bz2 compression.
Raymond Hettinger <python@rcn.com>
parents:
30505
diff
changeset
|
914 {byte string} |
|
db63cb0fc7da
Added codec for bz2 compression.
Raymond Hettinger <python@rcn.com>
parents:
30505
diff
changeset
|
915 {Compress the operand using bz2} |
|
db63cb0fc7da
Added codec for bz2 compression.
Raymond Hettinger <python@rcn.com>
parents:
30505
diff
changeset
|
916 |
|
26943
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
917 \lineiv{hex_codec} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
918 {hex} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
919 {byte string} |
|
28906
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
920 {Convert operand to hexadecimal representation, with two |
|
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
921 digits per byte} |
|
26943
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
922 |
|
28671
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
923 \lineiv{idna} |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
924 {} |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
925 {Unicode string} |
|
28906
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
926 {Implements \rfc{3490}. |
| 30273 | 927 \versionadded{2.3} |
|
28906
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
928 See also \refmodule{encodings.idna}} |
|
28671
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
929 |
|
26943
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
930 \lineiv{mbcs} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
931 {dbcs} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
932 {Unicode string} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
933 {Windows only: Encode operand according to the ANSI codepage (CP_ACP)} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
934 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
935 \lineiv{palmos} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
936 {} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
937 {Unicode string} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
938 {Encoding of PalmOS 3.5} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
939 |
|
28671
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
940 \lineiv{punycode} |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
941 {} |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
942 {Unicode string} |
|
28906
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
943 {Implements \rfc{3492}. |
|
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
944 \versionadded{2.3}} |
|
28671
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
945 |
|
26943
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
946 \lineiv{quopri_codec} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
947 {quopri, quoted-printable, quotedprintable} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
948 {byte string} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
949 {Convert operand to MIME quoted printable} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
950 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
951 \lineiv{raw_unicode_escape} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
952 {} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
953 {Unicode string} |
|
28906
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
954 {Produce a string that is suitable as raw Unicode literal in |
|
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
955 Python source code} |
|
26943
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
956 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
957 \lineiv{rot_13} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
958 {rot13} |
|
37523
0a014884017c
Bug #1465619: rot13 codec decodes to a Unicode string.
Georg Brandl <georg@python.org>
parents:
35952
diff
changeset
|
959 {Unicode string} |
|
26943
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
960 {Returns the Caesar-cypher encryption of the operand} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
961 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
962 \lineiv{string_escape} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
963 {} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
964 {byte string} |
|
28906
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
965 {Produce a string that is suitable as string literal in |
|
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
966 Python source code} |
|
26943
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
967 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
968 \lineiv{undefined} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
969 {} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
970 {any} |
|
28906
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
971 {Raise an exception for all conversion. Can be used as the |
|
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
972 system encoding if no automatic coercion between byte and |
|
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
973 Unicode strings is desired.} |
|
26943
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
974 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
975 \lineiv{unicode_escape} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
976 {} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
977 {Unicode string} |
|
28906
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
978 {Produce a string that is suitable as Unicode literal in |
|
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
979 Python source code} |
|
26943
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
980 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
981 \lineiv{unicode_internal} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
982 {} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
983 {Unicode string} |
|
34296
67f2190e1f6d
SF Patch #1093896: miscellaneous doc typos
Raymond Hettinger <python@rcn.com>
parents:
33437
diff
changeset
|
984 {Return the internal representation of the operand} |
|
26943
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
985 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
986 \lineiv{uu_codec} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
987 {uu} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
988 {byte string} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
989 {Convert the operand using uuencode} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
990 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
991 \lineiv{zlib_codec} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
992 {zip, zlib} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
993 {byte string} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
994 {Compress the operand using gzip} |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
995 |
|
55141144dab5
Document standard encodings.
Martin v. Löwis <martin@v.loewis.de>
parents:
26294
diff
changeset
|
996 \end{tableiv} |
|
28671
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
997 |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
998 \subsection{\module{encodings.idna} --- |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
999 Internationalized Domain Names in Applications} |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1000 |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1001 \declaremodule{standard}{encodings.idna} |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1002 \modulesynopsis{Internationalized Domain Names implementation} |
|
28906
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
1003 % XXX The next line triggers a formatting bug, so it's commented out |
|
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
1004 % until that can be fixed. |
|
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
1005 %\moduleauthor{Martin v. L\"owis} |
|
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
1006 |
|
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
1007 \versionadded{2.3} |
|
28671
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1008 |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1009 This module implements \rfc{3490} (Internationalized Domain Names in |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1010 Applications) and \rfc{3492} (Nameprep: A Stringprep Profile for |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1011 Internationalized Domain Names (IDN)). It builds upon the |
|
29894
ac84f179bb84
A variety of markup-level adjustments.
Fred Drake <fdrake@acm.org>
parents:
29528
diff
changeset
|
1012 \code{punycode} encoding and \refmodule{stringprep}. |
|
28671
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1013 |
|
28906
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
1014 These RFCs together define a protocol to support non-\ASCII{} characters |
|
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
1015 in domain names. A domain name containing non-\ASCII{} characters (such |
|
29894
ac84f179bb84
A variety of markup-level adjustments.
Fred Drake <fdrake@acm.org>
parents:
29528
diff
changeset
|
1016 as ``www.Alliancefran\c caise.nu'') is converted into an |
|
28906
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
1017 \ASCII-compatible encoding (ACE, such as |
|
28671
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1018 ``www.xn--alliancefranaise-npb.nu''). The ACE form of the domain name |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1019 is then used in all places where arbitrary characters are not allowed |
|
28906
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
1020 by the protocol, such as DNS queries, HTTP \mailheader{Host} fields, and so |
|
28671
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1021 on. This conversion is carried out in the application; if possible |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1022 invisible to the user: The application should transparently convert |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1023 Unicode domain labels to IDNA on the wire, and convert back ACE labels |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1024 to Unicode before presenting them to the user. |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1025 |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1026 Python supports this conversion in several ways: The \code{idna} codec |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1027 allows to convert between Unicode and the ACE. Furthermore, the |
|
29894
ac84f179bb84
A variety of markup-level adjustments.
Fred Drake <fdrake@acm.org>
parents:
29528
diff
changeset
|
1028 \refmodule{socket} module transparently converts Unicode host names to |
|
28671
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1029 ACE, so that applications need not be concerned about converting host |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1030 names themselves when they pass them to the socket module. On top of |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1031 that, modules that have host names as function parameters, such as |
|
29894
ac84f179bb84
A variety of markup-level adjustments.
Fred Drake <fdrake@acm.org>
parents:
29528
diff
changeset
|
1032 \refmodule{httplib} and \refmodule{ftplib}, accept Unicode host names |
|
ac84f179bb84
A variety of markup-level adjustments.
Fred Drake <fdrake@acm.org>
parents:
29528
diff
changeset
|
1033 (\refmodule{httplib} then also transparently sends an IDNA hostname in |
|
ac84f179bb84
A variety of markup-level adjustments.
Fred Drake <fdrake@acm.org>
parents:
29528
diff
changeset
|
1034 the \mailheader{Host} field if it sends that field at all). |
|
28671
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1035 |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1036 When receiving host names from the wire (such as in reverse name |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1037 lookup), no automatic conversion to Unicode is performed: Applications |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1038 wishing to present such host names to the user should decode them to |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1039 Unicode. |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1040 |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1041 The module \module{encodings.idna} also implements the nameprep |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1042 procedure, which performs certain normalizations on host names, to |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1043 achieve case-insensitivity of international domain names, and to unify |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1044 similar characters. The nameprep functions can be used directly if |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1045 desired. |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1046 |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1047 \begin{funcdesc}{nameprep}{label} |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1048 Return the nameprepped version of \var{label}. The implementation |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1049 currently assumes query strings, so \code{AllowUnassigned} is |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1050 true. |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1051 \end{funcdesc} |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1052 |
| 29528 | 1053 \begin{funcdesc}{ToASCII}{label} |
|
28906
1eac1a35b370
- comment out \moduleauthor that broke formatting until the formatting
Fred Drake <fdrake@acm.org>
parents:
28682
diff
changeset
|
1054 Convert a label to \ASCII, as specified in \rfc{3490}. |
|
28671
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1055 \code{UseSTD3ASCIIRules} is assumed to be false. |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1056 \end{funcdesc} |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1057 |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1058 \begin{funcdesc}{ToUnicode}{label} |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1059 Convert a label to Unicode, as specified in \rfc{3490}. |
|
d41d8de9768f
Implement IDNA (Internationalized Domain Names in Applications).
Martin v. Löwis <martin@v.loewis.de>
parents:
27555
diff
changeset
|
1060 \end{funcdesc} |
