ñÕYftã@sªdZddlZddlZejZddd„ZGdd„dejƒZGdd „d ejƒZGd d „d ej ƒZ Gd d „d ej ƒZ dd„Z dS)z‚ Python 'utf-16' Codec Written by Marc-Andre Lemburg (mal@lemburg.com). (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. éNÚstrictcCstj||dƒS)NT)ÚcodecsÚ utf_16_decode)ÚinputÚerrors©rú5/opt/alt/python35/lib64/python3.5/encodings/utf_16.pyÚdecodesr c@sReZdZddd„Zddd„Zdd„Zd d „Zd d „Zd S)ÚIncrementalEncoderrcCs tjj||ƒd|_dS)N)rr Ú__init__Úencoder)Úselfrrrrr szIncrementalEncoder.__init__FcCsm|jdkrVtj||jƒd}tjdkrFtj|_n tj|_|S|j||jƒdS)NrÚlittle)r rÚ utf_16_encoderÚsysÚ byteorderÚutf_16_le_encodeÚutf_16_be_encode)r rÚfinalÚresultrrrÚencodes zIncrementalEncoder.encodecCstjj|ƒd|_dS)N)rr Úresetr )r rrrr!szIncrementalEncoder.resetcCs|jdkrdSdS)Nér)r )r rrrÚgetstate%szIncrementalEncoder.getstatecCs@|rd|_n*tjdkr0tj|_n tj|_dS)Nr)r rrrrr)r ÚstaterrrÚsetstate,s  zIncrementalEncoder.setstateN)Ú__name__Ú __module__Ú __qualname__r rrrrrrrrr s   r c@sOeZdZddd„Zdd„Zdd„Zdd „Zd d „Zd S) ÚIncrementalDecoderrcCs tjj||ƒd|_dS)N)rÚBufferedIncrementalDecoderr Údecoder)r rrrrr 6szIncrementalDecoder.__init__cCsž|jdkrˆtj||d|ƒ\}}}|dkrKtj|_n3|dkrftj|_n|dkr~tdƒ‚||fS|j||j|ƒS)Nrérz%UTF-16 stream does not start with BOMéÿÿÿÿ)r!rÚutf_16_ex_decodeÚutf_16_le_decodeÚutf_16_be_decodeÚ UnicodeErrorr)r rrrÚoutputÚconsumedrrrrÚ_buffer_decode:s!     z!IncrementalDecoder._buffer_decodecCstjj|ƒd|_dS)N)rr rr!)r rrrrGszIncrementalDecoder.resetcCs`tjj|ƒd}|jdkr/|dfSttjdk|jtjkkƒ}||fS)NrrÚbig)rr rr!Úintrrr&)r rZaddstaterrrrKs  zIncrementalDecoder.getstatecCs�tjj||ƒ|d}|dkrPtjdkrAtjntj|_n<|dkrƒtjdkrttjntj|_n d|_dS)Nr"rr+)rr rrrr&r%r!)r rrrrrYs   zIncrementalDecoder.setstateN)rrrr r*rrrrrrrr5s   rc@s:eZdZddd„Zdd„Zddd„ZdS) Ú StreamWriterrcCs#tjj|||ƒd|_dS)N)rr-r r )r Ústreamrrrrr iszStreamWriter.__init__cCstjj|ƒd|_dS)N)rr-rr )r rrrrmszStreamWriter.resetcCsc|jdkrOtj||ƒ}tjdkr?tj|_n tj|_|S|j||ƒSdS)Nr)r rrrrrr)r rrrrrrrqs zStreamWriter.encodeN)rrrr rrrrrrr-hs  r-c@s+eZdZdd„Zddd„ZdS)Ú StreamReaderc Cs3tjj|ƒy |`Wntk r.YnXdS)N)rr/rr ÚAttributeError)r rrrr~s   zStreamReader.resetrcCsytj||ddƒ\}}}|dkr<tj|_n3|dkrWtj|_n|dkrotdƒ‚||fS)NrFr"rz%UTF-16 stream does not start with BOMr#)rr$r%r r&r')r rrÚobjectr)rrrrr …s!    zStreamReader.decodeN)rrrrr rrrrr/|s  r/cCs4tjdddtdtdtdtdtdtƒS) NÚnamezutf-16rr ÚincrementalencoderÚincrementaldecoderÚ streamreaderÚ streamwriter)rÚ CodecInforr r rr/r-rrrrÚ getregentry’s r8) Ú__doc__rrrrr r r rr-r/r8rrrrÚs #3