• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1""" Python 'utf-16-le' Codec
2
3
4Written by Marc-Andre Lemburg (mal@lemburg.com).
5
6(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
7
8"""
9import codecs
10
11### Codec APIs
12
13encode = codecs.utf_16_le_encode
14
15def decode(input, errors='strict'):
16    return codecs.utf_16_le_decode(input, errors, True)
17
18class IncrementalEncoder(codecs.IncrementalEncoder):
19    def encode(self, input, final=False):
20        return codecs.utf_16_le_encode(input, self.errors)[0]
21
22class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
23    _buffer_decode = codecs.utf_16_le_decode
24
25class StreamWriter(codecs.StreamWriter):
26    encode = codecs.utf_16_le_encode
27
28class StreamReader(codecs.StreamReader):
29    decode = codecs.utf_16_le_decode
30
31### encodings module API
32
33def getregentry():
34    return codecs.CodecInfo(
35        name='utf-16-le',
36        encode=encode,
37        decode=decode,
38        incrementalencoder=IncrementalEncoder,
39        incrementaldecoder=IncrementalDecoder,
40        streamreader=StreamReader,
41        streamwriter=StreamWriter,
42    )
43