
    dt                         d Z ddlZddlZej        ZddZ G d dej                  Z G d dej                  Z G d	 d
ej	                  Z	 G d dej
                  Z
d ZdS )z Python 'utf-16' Codec


Written by Marc-Andre Lemburg (mal@lemburg.com).

(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.

    Nstrictc                 .    t          j        | |d          S )NT)codecsutf_16_decode)inputerrorss     "  /croot/python-split_1694437901252/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib/python3.11/encodings/utf_16.pydecoder
      s    vt444    c                   0    e Zd Zd	dZd
dZd Zd Zd ZdS )IncrementalEncoderr   c                 T    t           j                            | |           d | _        d S N)r   r   __init__encoderselfr   s     r	   r   zIncrementalEncoder.__init__   s&    !**4888r   Fc                     | j         Ut          j        || j                  d         }t          j        dk    rt          j        | _         nt          j        | _         |S |                      || j                  d         S )Nr   little)r   r   utf_16_encoder   sys	byteorderutf_16_le_encodeutf_16_be_encode)r   r   finalresults       r	   encodezIncrementalEncoder.encode   sf    <)%==a@F}((%6%6M||E4;//22r   c                 R    t           j                            |            d | _        d S r   )r   r   resetr   r   s    r	   r   zIncrementalEncoder.reset!   s$    !''---r   c                     | j         dndS )N   r   )r   r    s    r	   getstatezIncrementalEncoder.getstate%   s    
 \)q1r   c                     |r	d | _         d S t          j        dk    rt          j        | _         d S t          j        | _         d S Nr   )r   r   r   r   r   r   r   states     r	   setstatezIncrementalEncoder.setstate,   s>     	7DLLL}((%6%6r   Nr   )F)__name__
__module____qualname__r   r   r   r#   r(    r   r	   r   r      si           3 3 3 3  2 2 27 7 7 7 7r   r   c                   .    e Zd ZddZd Zd Zd Zd ZdS )	IncrementalDecoderr   c                 T    t           j                            | |           d | _        d S r   )r   BufferedIncrementalDecoderr   decoderr   s     r	   r   zIncrementalDecoder.__init__6   s&    )224@@@r   c                    | j         dt          j        ||d|          \  }}}|dk    rt          j        | _         n-|dk    rt          j        | _         n|dk    rt          d          ||fS |                      || j        |          S )Nr      r"   %UTF-16 stream does not start with BOM)r2   r   utf_16_ex_decodeutf_16_le_decodeutf_16_be_decodeUnicodeErrorr   )r   r   r   r   outputconsumedr   s          r	   _buffer_decodez!IncrementalDecoder._buffer_decode:   s    <'vq%@@ *VXyB%6a%6Q"#JKKKH%%||E4;666r   c                 R    t           j                            |            d | _        d S r   )r   r1   r   r2   r    s    r	   r   zIncrementalDecoder.resetG   s$    )//555r   c                     t           j                            |           d         }| j        |dfS t	          t
          j        dk    | j        t           j        u k              }||fS )Nr   r"   big)r   r1   r#   r2   intr   r   r9   )r   r'   addstates      r	   r#   zIncrementalDecoder.getstateK   sk     1::4@@C
 <1:.(??A B Bx  r   c                 8   t           j                            | |           |d         }|dk    r/t          j        dk    rt           j        nt           j        | _        d S |dk    r/t          j        dk    rt           j        nt           j        | _        d S d | _        d S )Nr5   r   r@   )r   r1   r(   r   r   r9   r8   r2   r&   s     r	   r(   zIncrementalDecoder.setstateY   s    )224???aA::"}55 #33!'!8 LLL aZZ"}55 #33!'!8 LLL  DLLLr   Nr)   )r*   r+   r,   r   r=   r   r#   r(   r-   r   r	   r/   r/   5   sd           7 7 7  ! ! !         r   r/   c                   $    e Zd ZddZd ZddZdS )StreamWriterr   c                 V    t           j                            | ||           d | _        d S r   )r   rE   r   r   )r   streamr   s      r	   r   zStreamWriter.__init__i   s(    $$T66:::r   c                 R    t           j                            |            d | _        d S r   )r   rE   r   r   r    s    r	   r   zStreamWriter.resetm   s$    !!$'''r   c                     | j         Jt          j        ||          }t          j        dk    rt          j        | _         nt          j        | _         |S |                      ||          S r%   )r   r   r   r   r   r   r   )r   r   r   r   s       r	   r   zStreamWriter.encodeq   sX    <)%88F}((%6%6M<<v...r   Nr)   )r*   r+   r,   r   r   r   r-   r   r	   rE   rE   h   sK             	/ 	/ 	/ 	/ 	/ 	/r   rE   c                       e Zd Zd ZddZdS )StreamReaderc                 l    t           j                            |            	 | `d S # t          $ r Y d S w xY wr   )r   rK   r   r
   AttributeErrorr    s    r	   r   zStreamReader.reset~   sI    !!$'''	 	 	 	DD	s   % 
33r   c                     t          j        ||dd          \  }}}|dk    rt           j        | _        n-|dk    rt           j        | _        n|dk    rt          d          ||fS )Nr   Fr4   r5   r"   r6   )r   r7   r8   r
   r9   r:   )r   r   r   objectr<   r   s         r	   r
   zStreamReader.decode   sn    #E61e<< 	&9?? 1DKK!^^ 1DKKq[[FGGG!!r   Nr)   )r*   r+   r,   r   r
   r-   r   r	   rK   rK   |   s7          	" 	" 	" 	" 	" 	"r   rK   c            	      t    t          j        dt          t          t          t
          t          t                    S )Nzutf-16)namer   r
   incrementalencoderincrementaldecoderstreamreaderstreamwriter)r   	CodecInfor   r
   r   r/   rK   rE   r-   r   r	   getregentryrW      s1    --!!   r   r)   )__doc__r   r   r   r   r
   r   r1   r/   rE   rK   rW   r-   r   r	   <module>rY      s            
	5 5 5 5!7 !7 !7 !7 !72 !7 !7 !7F1  1  1  1  1 : 1  1  1 f/ / / / /6& / / /(" " " " "6& " " ",	 	 	 	 	r   