o
    ¨Êh  ã                   @   sD   d Z ddlZddlmZ i Zdd„ Zdd„ Zdd	„ ZeZd
d„ Z	dS )u«  Transliterate Unicode text into plain 7-bit ASCII.

Example usage:
>>> from unidecode import unidecode:
>>> unidecode(u"åŒ—äº°")
"Bei Jing "

The transliteration uses a straightforward map, and doesn't have alternatives
for the same character based on language, position, or anything else.

In Python 3, a standard string object will be returned. If you need bytes, use:
>>> unidecode("ÎšÎ½Ï‰ÏƒÏŒÏ‚").encode("ascii")
b'Knosos'
é    N)Úversion_infoc                 C   s:   t d dk rt| tƒst dt| ƒf td¡ d S d S d S )Nr   é   zdArgument %r is not an unicode object. Passing an encoded string will likely have unexpected results.é   )r   Ú
isinstanceÚunicodeÚwarningsÚwarnÚtypeÚRuntimeWarning©Ústring© r   úD/var/www/html/env/lib/python3.10/site-packages/unidecode/__init__.pyÚ_warn_if_not_unicode   s   þýÿr   c                 C   sF   t | ƒ z|  d¡}W n ty   t| ƒ Y S w td dkr!| S |S )uÒ  Transliterate an Unicode object into an ASCII string

    >>> unidecode(u"åŒ—äº°")
    "Bei Jing "

    This function first tries to convert the string using ASCII codec.
    If it fails (because of non-ASCII characters), it falls back to
    transliteration using the character tables.

    This is approx. five times faster if the string only contains ASCII
    characters, but slightly slower than using unidecode directly if non-ASCII
    chars are present.
    ÚASCIIr   r   )r   ÚencodeÚUnicodeEncodeErrorÚ
_unidecoder   )r   Ú
bytestringr   r   r   Úunidecode_expect_ascii   s   ÿr   c                 C   s   t | ƒ t| ƒS )ug   Transliterate an Unicode object into an ASCII string

    >>> unidecode(u"åŒ—äº°")
    "Bei Jing "
    )r   r   r   r   r   r   Úunidecode_expect_nonascii8   s   r   c                 C   s  g }| D ]x}t |ƒ}|dk r| t|ƒ¡ q|dkrqd|  kr%dkr1n n
t d|f td¡ |d? }|d }zt| }W n- tyl   ztd	| t	ƒ t
ƒ d
gƒ}W n tyb   d t|< Y Y qw |j t|< }Y nw |r|t|ƒ|kr|| || ¡ qd |¡S )Né€   iÿÿ i Ø  iÿß  zQSurrogate character %r will be ignored. You might be using a narrow Python build.r   é   é   zunidecode.x%03xÚdataÚ )ÚordÚappendÚstrr   r   r
   ÚCacheÚKeyErrorÚ
__import__ÚglobalsÚlocalsÚImportErrorr   ÚlenÚjoin)r   ÚretvalÚcharÚ	codepointÚsectionÚpositionÚtableÚmodr   r   r   r   D   s>   ÿþþù	€
r   )
Ú__doc__r   Úsysr   r   r   r   r   Ú	unidecoder   r   r   r   r   Ú<module>   s   
