
    i	                         S r SSKrSSKrS r\R                  " S\R
                  5      r\R                  " S\R
                  5      rS r\	S:X  a  SSK
r
\" S\
R                  " 5       5        gg)	zhPython implementation of ASCII85/ASCIIHex decoder (Adobe version).

This code is in the public domain.

    Nc                 l   S=pSnU  H  nSU::  a=  US::  a7  US-  nUS-  US-
  -   nUS:X  a  U[         R                  " SU5      -  nS=pMD  MF  US	:X  a  US:X  d   eUS
-  nM[  US:X  d  Mc  U(       a=  [        SU-
  5       H  nUS-  S-   nM     U[         R                  " SU5      SUS-
   -  n  U$    U$ )a)  
In ASCII85 encoding, every four bytes are encoded with five ASCII
letters, using 85 different types of characters (as 256**4 < 85**5).
When the length of the original bytes is not a multiple of 4, a special
rule is used for round up.

The Adobe's ASCII85 implementation is slightly different from
its original in handling the last characters.

The sample string is taken from:
  http://en.wikipedia.org/w/index.php?title=Ascii85

>>> ascii85decode(b'9jqo^BlbD-BleB1DJ+*+F(f,q')
b'Man is distinguished'
>>> ascii85decode(b'E,9)oF*2M7/c~>')
b'pleasure.'
r       !   u      U      z>Lz   s       ~   T   N)structpackrange)datanboutc_s         C/home/kodi/my-venv/lib/python3.13/site-packages/pdfminer/ascii85.pyascii85decoder      s    $ IA
C7qCxFA"adAAvv{{4++	A  #X6M6;C#XqsA"RA $v{{4+DQqS11J!   Jr   z([a-f\d]{2})z#^(?:[a-f\d]{2}|\s)*([a-f\d])[\s>]*$c                 4   U R                  S5      n [        R                  U 5       Vs/ s H  n[        US5      PM     nn[        R                  U 5      nU(       a-  UR                  [        UR                  S5      S5      S-  5        [        U5      $ s  snf )aO  
ASCIIHexDecode filter: PDFReference v1.4 section 3.3.1
For each pair of ASCII hexadecimal digits (0-9 and A-F or a-f), the
ASCIIHexDecode filter produces one byte of binary data. All white-space
characters are ignored. A right angle bracket character (>) indicates
EOD. Any other characters will cause an error. If the filter encounters
the EOD marker after reading an odd number of hexadecimal digits, it
will behave as if a 0 followed the last digit.

>>> asciihexdecode(b'61 62 2e6364   65')
b'ab.cde'
>>> asciihexdecode(b'61 62 2e6364   657>')
b'ab.cdep'
>>> asciihexdecode(b'7>')
b'p'
latin1   r      )	decodehex_refindallinttrail_researchappendgroupbytes)r   hxr   ms       r   asciihexdecoder'   9   sw    " ;;x D"(.."6
8"62C2J"6C
8A

3qwwqz"%*+:	 9s   B__main__zpdfminer.ascii85)__doc__rer   r   compile
IGNORECASEr   r    r'   __name__doctestprinttestmod r   r   <module>r2      sl    
 $N 
OR]]	3::<bmmL2 z	
goo/0 r   