Back to index

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

List of all members.

Public Member Functions

def __init__
def reset
def getstate
def setstate
def decode

Public Attributes

 decoder
 buffer
 errors
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Private Member Functions

def _buffer_decode

Detailed Description

Definition at line 53 of file utf_16.py.


Constructor & Destructor Documentation

def encodings.utf_16.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 54 of file utf_16.py.

00054 
00055     def __init__(self, errors='strict'):
00056         codecs.BufferedIncrementalDecoder.__init__(self, errors)
00057         self.decoder = None

Here is the call graph for this function:

Here is the caller graph for this function:


Member Function Documentation

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

Reimplemented from codecs.BufferedIncrementalDecoder.

Definition at line 58 of file utf_16.py.

00058 
00059     def _buffer_decode(self, input, errors, final):
00060         if self.decoder is None:
00061             (output, consumed, byteorder) = \
00062                 codecs.utf_16_ex_decode(input, errors, 0, final)
00063             if byteorder == -1:
00064                 self.decoder = codecs.utf_16_le_decode
00065             elif byteorder == 1:
00066                 self.decoder = codecs.utf_16_be_decode
00067             elif consumed >= 2:
00068                 raise UnicodeError("UTF-16 stream does not start with BOM")
00069             return (output, consumed)
00070         return self.decoder(input, self.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_16.py.

00075 
00076     def getstate(self):
00077         # additonal state info from the base class must be None here,
00078         # as it isn't passed along to the caller
00079         state = codecs.BufferedIncrementalDecoder.getstate(self)[0]
00080         # additional state info we pass to the caller:
00081         # 0: stream is in natural order for this platform
00082         # 1: stream is in unnatural order
00083         # 2: endianness hasn't been determined yet
00084         if self.decoder is None:
00085             return (state, 2)
00086         addstate = int((sys.byteorder == "big") !=
00087                        (self.decoder is codecs.utf_16_be_decode))
00088         return (state, addstate)

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_16.py.

00071 
00072     def reset(self):
00073         codecs.BufferedIncrementalDecoder.reset(self)
00074         self.decoder = None

Here is the call graph for this function:

Here is the caller graph for this function:

def encodings.utf_16.IncrementalDecoder.setstate (   self,
  state 
)
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 89 of file utf_16.py.

00089 
00090     def setstate(self, state):
00091         # state[1] will be ignored by BufferedIncrementalDecoder.setstate()
00092         codecs.BufferedIncrementalDecoder.setstate(self, state)
00093         state = state[1]
00094         if state == 0:
00095             self.decoder = (codecs.utf_16_be_decode
00096                             if sys.byteorder == "big"
00097                             else codecs.utf_16_le_decode)
00098         elif state == 1:
00099             self.decoder = (codecs.utf_16_le_decode
00100                             if sys.byteorder == "big"
00101                             else codecs.utf_16_be_decode)
00102         else:
00103             self.decoder = None

Here is the call graph for this function:


Member Data Documentation

Definition at line 290 of file codecs.py.

Definition at line 56 of file utf_16.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 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: