
    Rh                         d Z ddlZddlZddlmZ i ZdZdgZej                  Z G d de	e
      Zd	 Zd
 Z ej                  e       ej                  dk(  rd Z ej                  e       yy)a2   Standard "encodings" Package

    Standard Python encoding modules are stored in this package
    directory.

    Codec modules must have names corresponding to normalized encoding
    names as defined in the normalize_encoding() function below, e.g.
    'utf-8' must be implemented by the module 'utf_8.py'.

    Each codec module must export the following interface:

    * getregentry() -> codecs.CodecInfo object
    The getregentry() API must return a CodecInfo object with encoder, decoder,
    incrementalencoder, incrementaldecoder, streamwriter and streamreader
    attributes which adhere to the Python Codec Interface Standard.

    In addition, a module may optionally also define the following
    APIs which are then used by the package's codec search function:

    * getaliases() -> sequence of encoding name strings to use as aliases

    Alias names returned by getaliases() must be normalized encoding
    names as defined by normalize_encoding().

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

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

    N   )aliasesz--unknown--*c                       e Zd Zy)CodecRegistryErrorN)__name__
__module____qualname__     )/usr/lib/python3.12/encodings/__init__.pyr   r   (   s    r   r   c                    t        | t              rt        | d      } g }d}| D ]R  }|j                         s|dk(  r9|r|r|j	                  d       |j                         r|j	                  |       d}Qd}T dj                  |      S )ae   Normalize an encoding name.

        Normalization works as follows: all non-alphanumeric
        characters except the dot used for Python package names are
        collapsed and replaced with a single underscore, e.g. '  -;#'
        becomes '_'. Leading and trailing underscores are removed.

        Note that encoding names should be ASCII only.

    asciiF._T )
isinstancebytesstrisalnumappendisasciijoin)encodingcharspunctcs       r   normalize_encodingr   +   s     (E"x)EE 99;!s(S!yy{QEE 775>r   c                    t         j                  | t              }|t        ur|S t        |       }t        j                  |      xs% t        j                  |j                  dd            }|||g}n|g}|D ]   }|rd|v r
	 t        d|z   t        d      } n d }	 |j                  }|
d t         | <   y         }t        |t        j                        s@dt        |      cxk  rdk  s(n t        d|j                   d	|j"                  d
      t%        |d         rvt%        |d         rh|d   t%        |d         rU|d   t%        |d         rBt        |      dkD  r|d   t%        |d         r!t        |      dkD  r9|d   4t%        |d         s&t        d|j                   d	|j"                  d      t        |      dk  s|d   5|ddt        |      z
  z  |j                   j'                  dd      d   fz   z  }t        j                  | }|t         | <   	 |j)                         }|D ]  }	|	t        vst        |	<    |S # t        $ r Y w xY w# t        $ r d }Y w xY w# t        $ r Y |S w xY w)Nr   r   z
encodings.r   )fromlistlevel      zmodule "z" (z) failed to registerr            zincompatible codecs in module ")   )N)_cacheget_unknownr   _aliasesreplace
__import___import_tailImportErrorgetregentryAttributeErrorr   codecs	CodecInfolenr   r   __file__callablesplit
getaliases)
r   entrynorm_encodingaliased_encodingmodnamesmodnamemodr1   codecaliasesaliass
             r   search_functionrB   G   s    JJx*EH 'x0M||M2 E||M$9$9#s$CD #$!# "? #.
	 \G3l#$&C  oo
 {x MEeV--.CJ#!#$(+cll&D E Ea!%();!H %();!H %();JNuQx3HU1X<NJNuQx3HU1X<N$(+cll&D E Eu:a<58+WaE
l+s||/A/A#q/I!/L.NNNE  %( F8*~~' " 	*EH$")	*
 Li  	 	  B   Ls6   II "I/ 	III,+I,/	I<;I<win32c                     	 dd l }d|j                         z  }| |k(  rdd l}|j                  j	                         S y # t
        $ r Y y w xY w)Nr   zcp%s)_winapiGetACPencodings.mbcsmbcsr1   r0   )r   rE   ansi_code_page	encodingss       r   _alias_mbcsrK      sR    	#gnn&66N>)% ~~1133 *  		s   9= 	A	A	)__doc__r3   sysr   r   r)   r+   r/   r,   LookupErrorSystemErrorr   r   rB   registerplatformrK   r   r   r   <module>rR      s   <  
 	u??	k 	8Rj   <<7
	 FOOK ! r   