
    a                     4    d dl Z ddZddZddZddZddZy)    Nc                 R    |d}t        | t              r| j                  ||      S | S Nutf-8)
isinstancebytesdecodetextencodingerrorss      *lib/python3.12/site-packages/w3lib/util.pystr_to_unicoder      s-    ${{8V,,K    c                 f    |d}t        | t        j                        r| j                  ||      S | S r   )r   six	text_typeencoder	   s      r   unicode_to_strr   
   s1    $&{{8V,,Kr   c                     t        | t        j                        r| S t        | t        t        j                  f      s!t	        dt        |       j                  z        |d}| j                  ||      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 %sr   )r   r   r   r   	TypeErrortype__name__r   r	   s      r   
to_unicoder      sl     $&dUCMM23 )+/:+>+>? @ 	@;;x((r   c                     t        | t              r| S t        | t        j                        s!t	        dt        |       j                  z        |d}| j                  ||      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 %sr   )r   r   r   string_typesr   r   r   r   r	   s      r   to_bytesr      se     $dC,,- )+/:+>+>? @ 	@;;x((r   c                 V    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   )   s)     wwh//$&11r   )Nstrict)r   r   r   r   r   r    r   r   <module>r"      s!    

)
)2r   