
    .i                         d dl Z d dlZd dlmZmZmZmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ  ej        d          Z e j        e          Zded	efd
Zded	dfdZ G d d          ZdS )    N)DictIterableOptionalcast)glyphname2unicode)ENCODINGPDFKeyError)	PSLiteralz[0-9a-fA-F]+namereturnc                 >   t          | t                    s"t          d| dt          |                     |                     d          d         } |                     d          }t          |          dk    r(d                    t          t          |                    S | t          v rt          |          S | 
                    d          r|                     d          t                                        r~t                    d	z  dk    rhfd
t          dt                    d	          D             }|D ]}t          |           t          t           |          }d                    |          S n| 
                    d          r{|                     d          }t                              |          rLd	t          |          cxk    rdk    r2n n/t#          |d          }t          |           t!          |          S t          d| z            )a  Converts Adobe glyph names to Unicode numbers.

    In contrast to the specification, this raises a KeyError instead of return
    an empty string when the key is unknown.
    This way the caller must explicitly define what to do
    when there is not a match.

    Reference:
    https://github.com/adobe-type-tools/agl-specification#2-the-mapping

    :returns unicode character if name resembles something,
    otherwise a KeyError
    z Could not convert unicode name "z?" to character because it should be of type str but is of type .r   _    uni   c                 H    g | ]}t          ||d z            d          S )r      base)int).0iname_without_unis     O/var/www/html/analyses/venv/lib/python3.11/site-packages/pdfminer/encodingdb.py
<listcomp>z name2unicode.<locals>.<listcomp>0   sD        $QQY/b999      u   r   r   zXCould not convert unicode name "%s" to character because it does not match specification)
isinstancestrr
   typesplitlenjoinmapname2unicoder   
startswithstripHEXADECIMALmatchrange#raise_key_error_for_invalid_unicodechrr   )r   
componentsunicode_digitsdigit
charactersname_without_uunicode_digitr   s          @r   r)   r)      s1    dC   
k<@DD$t***N
 
 	

 ::c??1DCJ
:wws<44555	"	"	" &&			 &::e,,-.. 	'37G3H3H13LPQ3Q3Q   q#&6"7"7;;  N ( ; ;3E::::S.11J77:&&&			 &C^,, 	&c.6I6I1N1N1N1NQ1N1N1N1N1NR888M/>>>}%%%
	*,0	1  r   r6   c                 L    d| cxk     rdk     rn dS t          d| z            dS )zUnicode values should not be in the range D800 through DFFF because
    that is used for surrogate pairs in UTF-16

    :raises KeyError if unicode digit is invalid
    i  i   zHUnicode digit %d is invalid because it is in the range D800 through DFFFNr	   )r6   s    r   r/   r/   G   sQ     }$$$$u$$$$$$35BC
 
 	
 %$r   c            
       J   e Zd ZU i Zeeef         ed<   i Zeeef         ed<   i Z	eeef         ed<   i Z
eeef         ed<   eD ]/\  ZZZZZ ee          Zereee<   ereee<   eree	e<   eree
e<   0eee	e
dZe	 ddedeee                  d	eeef         fd
            ZdS )
EncodingDBstd2unicodemac2unicodewin2unicodepdf2unicode)StandardEncodingMacRomanEncodingWinAnsiEncodingPDFDocEncodingNr   diffr   c                    | j                             || j                  }|r|                                }d}|D ]}t	          |t
                    r|}t	          |t                    rv	 t          t          t          |j
                            ||<   nE# t          t          f$ r1}t                              t          |                     Y d }~nd }~ww xY w|dz  }|S )Nr   r   )	encodingsgetr:   copyr"   r   r   r)   r   r#   r   KeyError
ValueErrorlogdebug)clsr   rB   cid2unicodecidxes          r   get_encodingzEncodingDB.get_encodingk   s     m''co>> 	%**,,KC  a%% CC9-- *+7S!&8I8I+J+JC(($j1 * * *		#a&&))))))))*1HCs   +*BC''CC)N)__name__
__module____qualname__r:   r   r   r#   __annotations__r;   r<   r=   r   r   stdmacwinpdfr)   crD   classmethodr   r   objectrP    r   r   r9   r9   T   sZ        "$Kc3h$$$"$Kc3h$$$"$Kc3h$$$"$Kc3h$$$$, 	! 	! c3SL 	! K 	! K 	! K 	! K ('&%	 I  ,0  x'( 
c3h	   [  r   r9   )loggingretypingr   r   r   r   pdfminer.glyphlistr   pdfminer.latin_encr   pdfminer.pdfexceptionsr
   pdfminer.psparserr   compiler,   	getLoggerrQ   rI   r#   r)   r   r/   r9   r\   r   r   <module>rf      s    				 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 ' ' ' ' ' ' . . . . . . ' ' ' ' ' 'bj))g!!5s 5s 5 5 5 5p

s 

t 

 

 

 

* * * * * * * * * *r   