o ?Og%@stdZddlZdddZdddZGdd d ejZGd d d ejZGd d d ejZGdddejZddZ dS)a Python 'utf-8-sig' Codec This work similar to UTF-8 with the following changes: * On encoding/writing a UTF-8 encoded BOM will be prepended/written as the first three bytes. * On decoding/reading if the first three bytes are a UTF-8 encoded BOM, these bytes will be skipped. NstrictcCstjt||dt|fSNr)codecsBOM_UTF8 utf_8_encodelen)inputerrorsr :/opt/alt/python310/lib64/python3.10/encodings/utf_8_sig.pyencodesr cCsDd}|ddtjkr|dd}d}t||d\}}|||fS)NrT)rr utf_8_decode)rr prefixoutputconsumedr r r decodes   rc@s8eZdZdddZdddZddZd d Zd d Zd S)IncrementalEncoderrcCtj||d|_dSN)rr__init__firstselfr r r r r zIncrementalEncoder.__init__FcCs6|jrd|_tjt||jdSt||jdSr)rrrrr )rrfinalr r r r s zIncrementalEncoder.encodecCtj|d|_dSr)rrresetrrr r r r'  zIncrementalEncoder.resetcCs|jSNrrr r r getstate+szIncrementalEncoder.getstatecCs ||_dSr!r"rstater r r setstate.s zIncrementalEncoder.setstateNr)F)__name__ __module__ __qualname__rr rr#r&r r r r rs    rc@s6eZdZd ddZddZddZdd Zd d Zd S)IncrementalDecoderrcCrr)rBufferedIncrementalDecoderrrrr r r r2rzIncrementalDecoder.__init__cCsv|jr4t|dkrtj|rdSd|_nd|_|ddtjkr4t|dd||\}}||dfSt|||S)Nr rr)rrrr startswithr)rrr rrrr r r _buffer_decode6s   z!IncrementalDecoder._buffer_decodecCrr)rr,rrrr r r rGr zIncrementalDecoder.resetcCstj|}|d|jfSr)rr,r#rr$r r r r#Ks zIncrementalDecoder.getstatecCstj|||d|_dSr)rr,r&rr$r r r r&PszIncrementalDecoder.setstateNr')r(r)r*rr0rr#r&r r r r r+1s   r+c@eZdZddZdddZdS) StreamWritercC,tj|z|`WdStyYdSwr!)rr2rr AttributeErrorrr r r rV   zStreamWriter.resetrcCstj|_t||Sr!)rrr )rrr r r r r ]s zStreamWriter.encodeNr')r(r)r*rr r r r r r2Ur2c@r1) StreamReadercCr3r!)rr7rrr4rr r r rbr5zStreamReader.resetrcCspt|dkrtj|rdSn|ddtjkr.tj|_t|dd|\}}||dfStj|_t||S)Nr r-)rrrr/rr)rrr rrr r r ris    zStreamReader.decodeNr')r(r)r*rrr r r r r7ar6r7c CstjdttttttdS)Nz utf-8-sig)namer rincrementalencoderincrementaldecoder streamreader streamwriter)r CodecInfor rrr+r7r2r r r r getregentryysr>r') __doc__rr rrr,r+r2r7r>r r r r s  $