annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/python3.8/encodings/mbcs.py @ 68:5028fdace37b

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 16:23:26 -0400
parents
children
rev   line source
jpayne@68 1 """ Python 'mbcs' Codec for Windows
jpayne@68 2
jpayne@68 3
jpayne@68 4 Cloned by Mark Hammond (mhammond@skippinet.com.au) from ascii.py,
jpayne@68 5 which was written by Marc-Andre Lemburg (mal@lemburg.com).
jpayne@68 6
jpayne@68 7 (c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
jpayne@68 8
jpayne@68 9 """
jpayne@68 10 # Import them explicitly to cause an ImportError
jpayne@68 11 # on non-Windows systems
jpayne@68 12 from codecs import mbcs_encode, mbcs_decode
jpayne@68 13 # for IncrementalDecoder, IncrementalEncoder, ...
jpayne@68 14 import codecs
jpayne@68 15
jpayne@68 16 ### Codec APIs
jpayne@68 17
jpayne@68 18 encode = mbcs_encode
jpayne@68 19
jpayne@68 20 def decode(input, errors='strict'):
jpayne@68 21 return mbcs_decode(input, errors, True)
jpayne@68 22
jpayne@68 23 class IncrementalEncoder(codecs.IncrementalEncoder):
jpayne@68 24 def encode(self, input, final=False):
jpayne@68 25 return mbcs_encode(input, self.errors)[0]
jpayne@68 26
jpayne@68 27 class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
jpayne@68 28 _buffer_decode = mbcs_decode
jpayne@68 29
jpayne@68 30 class StreamWriter(codecs.StreamWriter):
jpayne@68 31 encode = mbcs_encode
jpayne@68 32
jpayne@68 33 class StreamReader(codecs.StreamReader):
jpayne@68 34 decode = mbcs_decode
jpayne@68 35
jpayne@68 36 ### encodings module API
jpayne@68 37
jpayne@68 38 def getregentry():
jpayne@68 39 return codecs.CodecInfo(
jpayne@68 40 name='mbcs',
jpayne@68 41 encode=encode,
jpayne@68 42 decode=decode,
jpayne@68 43 incrementalencoder=IncrementalEncoder,
jpayne@68 44 incrementaldecoder=IncrementalDecoder,
jpayne@68 45 streamreader=StreamReader,
jpayne@68 46 streamwriter=StreamWriter,
jpayne@68 47 )