
    a                     6    d dl Z ddZddZddZddZddZdS )	    Nstrictc                 d    |d}t          | t                    r|                     ||          S | S Nutf-8)
isinstancebytesdecodetextencodingerrorss      *lib/python3.11/site-packages/w3lib/util.pystr_to_unicoder      s8    $ -{{8V,,,K    c                 n    |d}t          | t          j                  r|                     ||          S | S r   )r   six	text_typeencoder
   s      r   unicode_to_strr   
   s:    $&& -{{8V,,,Kr   c                     t          | t          j                  r| S t          | t          t          j        f          s$t	          dt          |           j        z            |d}|                     ||          S )zxReturn the unicode representation of a bytes object `text`. If `text`
    is already an unicode object, return it as-is.z>to_unicode must receive a bytes, str or unicode object, got %sNr   )r   r   r   r   	TypeErrortype__name__r	   r
   s      r   
to_unicoder      s     $&& dUCM233 @ )+/::+>? @ @ 	@;;x(((r   c                     t          | t                    r| S t          | t          j                  s$t	          dt          |           j        z            |d}|                     ||          S )zeReturn the binary representation of `text`. If `text`
    is already a bytes object, return it as-is.z<to_bytes must receive a unicode, str or bytes object, got %sNr   )r   r   r   string_typesr   r   r   r   r
   s      r   to_bytesr      s{     $ dC,-- @ )+/::+>? @ @ 	@;;x(((r   c                 ^    t           j        rt          | ||          S t          | ||          S )zZ Return str representation of `text`
    (bytes in Python 2.x and unicode in Python 3.x). )r   PY2r   r   r
   s      r   to_native_strr    )   s2     w 2h///$&111r   )Nr   )r   r   r   r   r   r     r   r   <module>r"      s|    



      
) 
) 
) 
)
) 
) 
) 
)2 2 2 2 2 2r   