?ŠMa%ã@s¤dZddlZddd„Zddd„ZGdd „d ejƒZGd d „d ejƒZGd d „d ejƒZGdd„dejƒZdd„Z 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. éNÚstrictcCs'tjtj||ƒdt|ƒfS)Nr)ÚcodecsÚBOM_UTF8Ú utf_8_encodeÚlen)ÚinputÚerrors©r ú8/opt/alt/python35/lib64/python3.5/encodings/utf_8_sig.pyÚencodesr cCs^d}|dd…tjkr5|dd…}d}tj||dƒ\}}|||fS)NréT)rrÚ utf_8_decode)rrÚprefixÚoutputÚconsumedr r r Údecodes rc@sReZdZddd„Zddd„Zdd„Zd d „Zd d „Zd S)ÚIncrementalEncoderrcCs tjj||ƒd|_dS)Né)rrÚ__init__Úfirst)Úselfrr r r rszIncrementalEncoder.__init__FcCsK|jr0d|_tjtj||jƒdStj||jƒdSdS)Nr)rrrrr)rrÚfinalr r r r s   zIncrementalEncoder.encodecCstjj|ƒd|_dS)Nr)rrÚresetr)rr r r r'szIncrementalEncoder.resetcCs|jS)N)r)rr r r Úgetstate+szIncrementalEncoder.getstatecCs ||_dS)N)r)rÚstater r r Úsetstate.szIncrementalEncoder.setstateN)Ú__name__Ú __module__Ú __qualname__rr rrrr r r r rs   rc@sOeZdZddd„Zdd„Zdd„Zdd „Zd d „Zd S) ÚIncrementalDecoderrcCs tjj||ƒd|_dS)Nr)rÚBufferedIncrementalDecoderrr)rrr r r r2szIncrementalDecoder.__init__cCs¥|jr’t|ƒdkr=tjj|ƒr1dSd|_nUd|_|dd…tjkr’tj|dd…||ƒ\}}||dfStj|||ƒS)Nr Úr)r!r)rrrrÚ startswithr )rrrrrrr r r Ú_buffer_decode6s   %z!IncrementalDecoder._buffer_decodecCstjj|ƒd|_dS)Nr)rr rr)rr r r rGszIncrementalDecoder.resetcCs#tjj|ƒ}|d|jfS)Nr)rr rr)rrr r r rKszIncrementalDecoder.getstatecCs$tjj||ƒ|d|_dS)Nr)rr rr)rrr r r rPszIncrementalDecoder.setstateN)rrrrr#rrrr r r r r1s    rc@s+eZdZdd„Zddd„ZdS)Ú StreamWriterc Cs3tjj|ƒy |`Wntk r.YnXdS)N)rr$rr ÚAttributeError)rr r r rVs   zStreamWriter.resetrcCstj|_t||ƒS)N)rrr )rrrr r r r ]s zStreamWriter.encodeN)rrrrr r r r r r$Us  r$c@s+eZdZdd„Zddd„ZdS)Ú StreamReaderc Cs3tjj|ƒy |`Wntk r.YnXdS)N)rr&rrr%)rr r r rbs   zStreamReader.resetrcCsœt|ƒdkr+tjj|ƒr€dSnU|dd…tjkr€tj|_tj|dd…|ƒ\}}||dfStj|_tj||ƒS)Nr r!r)r!r)rrrr"r r)rrrrrr r r ris " zStreamReader.decodeN)rrrrrr r r r r&as  r&cCs4tjdddtdtdtdtdtdtƒS) NÚnamez utf-8-sigr rÚincrementalencoderÚincrementaldecoderÚ streamreaderÚ streamwriter)rÚ CodecInfor rrrr&r$r r r r Ú getregentryys r-) Ú__doc__rr rrr rr$r&r-r r r r Ú s $