mirror of
https://github.com/python/cpython.git
synced 2024-12-13 11:54:54 +08:00
69652035bc
decoding incomplete input (when the input stream is temporarily exhausted). codecs.StreamReader now implements buffering, which enables proper readline support for the UTF-16 decoders. codecs.StreamReader.read() has a new argument chars which specifies the number of characters to return. codecs.StreamReader.readline() and codecs.StreamReader.readlines() have a new argument keepends. Trailing "\n"s will be stripped from the lines if keepends is false. Added C APIs PyUnicode_DecodeUTF8Stateful and PyUnicode_DecodeUTF16Stateful.
30 lines
556 B
Python
30 lines
556 B
Python
""" Python 'utf-16-le' Codec
|
|
|
|
|
|
Written by Marc-Andre Lemburg (mal@lemburg.com).
|
|
|
|
(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
|
|
|
|
"""
|
|
import codecs
|
|
|
|
### Codec APIs
|
|
|
|
encode = codecs.utf_16_le_encode
|
|
|
|
def decode(input, errors='strict'):
|
|
return codecs.utf_16_le_decode(input, errors, True)
|
|
|
|
class StreamWriter(codecs.StreamWriter):
|
|
encode = codecs.utf_16_le_encode
|
|
|
|
class StreamReader(codecs.StreamReader):
|
|
decode = codecs.utf_16_le_decode
|
|
|
|
|
|
### encodings module API
|
|
|
|
def getregentry():
|
|
|
|
return (encode,decode,StreamReader,StreamWriter)
|