Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Member Functions
encodings.utf_8_sig.IncrementalDecoder Class Reference
Inheritance diagram for encodings.utf_8_sig.IncrementalDecoder:
Inheritance graph
[legend]
Collaboration diagram for encodings.utf_8_sig.IncrementalDecoder:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def reset
def getstate
def setstate
def decode

Public Attributes

 first
 buffer
 errors
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Private Member Functions

def _buffer_decode

Detailed Description

Definition at line 49 of file utf_8_sig.py.


Constructor & Destructor Documentation

def encodings.utf_8_sig.IncrementalDecoder.__init__ (   self,
  errors = 'strict' 
)
This subclass of IncrementalDecoder can be used as the baseclass for an
incremental decoder if the decoder must be able to handle incomplete
byte sequences.

Reimplemented from codecs.BufferedIncrementalDecoder.

Definition at line 50 of file utf_8_sig.py.

00050 
00051     def __init__(self, errors='strict'):
00052         codecs.BufferedIncrementalDecoder.__init__(self, errors)
00053         self.first = 1

Here is the call graph for this function:

Here is the caller graph for this function:


Member Function Documentation

def encodings.utf_8_sig.IncrementalDecoder._buffer_decode (   self,
  input,
  errors,
  final 
) [private]

Reimplemented from codecs.BufferedIncrementalDecoder.

Definition at line 54 of file utf_8_sig.py.

00054 
00055     def _buffer_decode(self, input, errors, final):
00056         if self.first:
00057             if len(input) < 3:
00058                 if codecs.BOM_UTF8.startswith(input):
00059                     # not enough data to decide if this really is a BOM
00060                     # => try again on the next call
00061                     return ("", 0)
00062                 else:
00063                     self.first = 0
00064             else:
00065                 self.first = 0
00066                 if input[:3] == codecs.BOM_UTF8:
00067                     (output, consumed) = \
00068                        codecs.utf_8_decode(input[3:], errors, final)
00069                     return (output, consumed+3)
00070         return codecs.utf_8_decode(input, errors, final)

def codecs.BufferedIncrementalDecoder.decode (   self,
  input,
  final = False 
) [inherited]
Decode input and returns the resulting object.

Reimplemented from codecs.IncrementalDecoder.

Definition at line 297 of file codecs.py.

00297 
00298     def decode(self, input, final=False):
00299         # decode input (taking the buffer into account)
00300         data = self.buffer + input
00301         (result, consumed) = self._buffer_decode(data, self.errors, final)
00302         # keep undecoded input until the next call
00303         self.buffer = data[consumed:]
00304         return result

Here is the call graph for this function:

Here is the caller graph for this function:

Return the current state of the decoder.

This must be a (buffered_input, additional_state_info) tuple.
buffered_input must be a bytes object containing bytes that
were passed to decode() that have not yet been converted.
additional_state_info must be a non-negative integer
representing the state of the decoder WITHOUT yet having
processed the contents of buffered_input.  In the initial state
and after reset(), getstate() must return (b"", 0).

Reimplemented from codecs.BufferedIncrementalDecoder.

Definition at line 75 of file utf_8_sig.py.

00075 
00076     def getstate(self):
00077         state = codecs.BufferedIncrementalDecoder.getstate(self)
00078         # state[1] must be 0 here, as it isn't passed along to the caller
00079         return (state[0], self.first)

Here is the call graph for this function:

Reset the decoder to the initial state.

Reimplemented from codecs.BufferedIncrementalDecoder.

Definition at line 71 of file utf_8_sig.py.

00071 
00072     def reset(self):
00073         codecs.BufferedIncrementalDecoder.reset(self)
00074         self.first = 1

Here is the call graph for this function:

Here is the caller graph for this function:

Set the current state of the decoder.

state must have been returned by getstate().  The effect of
setstate((b"", 0)) must be equivalent to reset().

Reimplemented from codecs.BufferedIncrementalDecoder.

Definition at line 80 of file utf_8_sig.py.

00080 
00081     def setstate(self, state):
00082         # state[1] will be ignored by BufferedIncrementalDecoder.setstate()
00083         codecs.BufferedIncrementalDecoder.setstate(self, state)
00084         self.first = state[1]

Here is the call graph for this function:


Member Data Documentation

Definition at line 290 of file codecs.py.

Create a IncrementalDecoder instance.

The IncrementalDecoder may use different error handling schemes by
providing the errors keyword argument. See the module docstring
for a list of possible values.

Reimplemented in encodings.bz2_codec.IncrementalDecoder, encodings.zlib_codec.IncrementalDecoder, encodings.base64_codec.IncrementalDecoder, and encodings.hex_codec.IncrementalDecoder.

Definition at line 246 of file codecs.py.

Definition at line 52 of file utf_8_sig.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.


The documentation for this class was generated from the following file: