Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
69ca950d
Kaydet (Commit)
69ca950d
authored
Nis 06, 2000
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Make sure the \declaremodule uses the right name for the module!
Clean up several markup problems & inconsistencies.
üst
343301aa
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
20 deletions
+22
-20
libcodecs.tex
Doc/lib/libcodecs.tex
+22
-20
No files found.
Doc/lib/libcodecs.tex
Dosyayı görüntüle @
69ca950d
\section
{
\module
{
codecs
}
---
\section
{
\module
{
codecs
}
---
Python c
odec registry and base classes
}
C
odec registry and base classes
}
\declaremodule
{
standard
}{
codec
}
\declaremodule
{
standard
}{
codec
s
}
\modulesynopsis
{
Encode and decode data and streams.
}
\modulesynopsis
{
Encode and decode data and streams.
}
\moduleauthor
{
Marc-Andre Lemburg
}{
mal@lemburg.com
}
\moduleauthor
{
Marc-Andre Lemburg
}{
mal@lemburg.com
}
\sectionauthor
{
Marc-Andre Lemburg
}{
mal@lemburg.com
}
\sectionauthor
{
Marc-Andre Lemburg
}{
mal@lemburg.com
}
...
@@ -35,20 +35,21 @@ return a tuple of functions \code{(\var{encoder}, \var{decoder}, \var{stream_rea
...
@@ -35,20 +35,21 @@ return a tuple of functions \code{(\var{encoder}, \var{decoder}, \var{stream_rea
\var
{
stream
_
reader
}
and
\var
{
stream
_
writer
}
: These have to be
\var
{
stream
_
reader
}
and
\var
{
stream
_
writer
}
: These have to be
factory functions providing the following interface:
factory functions providing the following interface:
\code
{
factory(
\var
{
stream
}
,
\var
{
errors
}
='strict')
}
\code
{
factory(
\var
{
stream
}
,
\var
{
errors
}
='strict')
}
The factory functions must return objects providing the interfaces
The factory functions must return objects providing the interfaces
defined by the base classes
defined by the base classes
\class
{
StreamWriter
}
and
\class
{
Stream
Writer
}
/
\class
{
StreamReader
}
resp. Stream codecs ca
n
\class
{
Stream
Reader
}
, respectively. Stream codecs can maintai
n
maintain
state.
state.
Possible values for errors are 'strict' (raise an exception in case
Possible values for errors are
\code
{
'strict'
}
(raise an exception
of an encoding error), 'replace' (replace malformed data with a
in case of an encoding error),
\code
{
'replace'
}
(replace malformed
suitable replacement marker, e.g. '?') and 'ignore' (ignore
data with a suitable replacement marker, such as
\character
{
?
}
) and
malformed data and continue without further notice).
\code
{
'ignore'
}
(ignore malformed data and continue without further
notice).
In case a search function cannot find a given encoding, it should
In case a search function cannot find a given encoding, it should
return
None
.
return
\code
{
None
}
.
\end{funcdesc}
\end{funcdesc}
\begin{funcdesc}
{
lookup
}{
encoding
}
\begin{funcdesc}
{
lookup
}{
encoding
}
...
@@ -57,20 +58,21 @@ function tuple as defined above.
...
@@ -57,20 +58,21 @@ function tuple as defined above.
Encodings are first looked up in the registry's cache. If not found,
Encodings are first looked up in the registry's cache. If not found,
the list of registered search functions is scanned. If no codecs tuple
the list of registered search functions is scanned. If no codecs tuple
is found, a
LookupError is raised. Otherwise, the codecs tuple i
s
is found, a
\exception
{
LookupError
}
is raised. Otherwise, the codec
s
stored in the cache and returned to the caller.
tuple is
stored in the cache and returned to the caller.
\end{funcdesc}
\end{funcdesc}
To simplify working with encoded files or stream, the module
To simplify working with encoded files or stream, the module
also defines these utility functions:
also defines these utility functions:
\begin{funcdesc}
{
open
}{
filename, mode
\optional
{
, encoding=None
, errors='strict', buffering=1
}}
\begin{funcdesc}
{
open
}{
filename, mode
\optional
{
, encoding=None
\optional
{
, errors='strict'
\optional
{
, buffering=1
}}
}}
Open an encoded file using the given
\var
{
mode
}
and return
Open an encoded file using the given
\var
{
mode
}
and return
a wrapped version providing transparent encoding/decoding.
a wrapped version providing transparent encoding/decoding.
Note: The wrapped version will only accept the object format defined
\strong
{
Note:
}
The wrapped version will only accept the object format
by the codecs, i.e. Unicode objects for most builtin codecs. Output is
defined by the codecs, i.e. Unicode objects for most builtin
also codec dependent and will usually by Unicode as well.
codecs. Output is also codec dependent and will usually by Unicode as
well.
\var
{
encoding
}
specifies the encoding which is to be used for the
\var
{
encoding
}
specifies the encoding which is to be used for the
the file.
the file.
...
@@ -79,11 +81,11 @@ the file.
...
@@ -79,11 +81,11 @@ the file.
to 'strict' which causes a
\exception
{
ValueError
}
to be raised in case
to 'strict' which causes a
\exception
{
ValueError
}
to be raised in case
an encoding error occurs.
an encoding error occurs.
\var
{
buffering
}
has the same meaning as for the built
in open() API.
\var
{
buffering
}
has the same meaning as for the built
-in
It defaults to line buffered.
\function
{
open()
}
function.
It defaults to line buffered.
\end{funcdesc}
\end{funcdesc}
\begin{funcdesc}
{
EncodedFile
}{
file, input
\optional
{
, output=None
, errors='strict'
}}
\begin{funcdesc}
{
EncodedFile
}{
file, input
\optional
{
, output=None
\optional
{
, errors='strict'
}
}}
Return a wrapped version of file which provides transparent
Return a wrapped version of file which provides transparent
encoding translation.
encoding translation.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment