o
    ë©Zh%  ã                   @   s   d Z ddlZdd„ Zdd„ Zeƒ Zdd„ edd	ƒD ƒZe e¡ e d
d„ edd	ƒD ƒ¡ dd„ Zde	fdd„Z
e d¡Zde	defdd„ZdS )zEncoding related utilities.é    Nc                 C   s   | dko| dk S )Né    é   © )Úir   r   úT/var/www/html/lang_env/lib/python3.10/site-packages/google/protobuf/text_encoding.pyÚ_AsciiIsPrint   s   r   c                  C   st   i } t ddƒD ]}t|ƒsd| | |< qd| tdƒ< d| tdƒ< d| td	ƒ< d
| tdƒ< d| tdƒ< d| tdƒ< | S )Nr   é€   ú\%03oz\tú	z\nÚ
z\rúz\"ú"z\'ú'z\\ú\)Úranger   Úord)Úretr   r   r   r   Ú_MakeStrEscapes   s   €r   c                 C   s   i | ]}|t |ƒ“qS r   )Úchr©Ú.0r   r   r   r   Ú
<dictcomp>   ó    r   é   c                 C   s   i | ]}|d | “qS )r	   r   r   r   r   r   r   !   r   r   c              
   C   s”   d}| rHz||   d¡ t¡7 }d} W n3 tyE } z'|| d |j…   d¡ t¡7 }|t| |j  7 }| |jd d … } W Y d }~nd }~ww | s|S )NÚ úutf-8é   )ÚdecodeÚ	translateÚ_str_escapesÚUnicodeDecodeErrorÚstartÚ_byte_escapes)Z
text_bytesr   Úer   r   r   Ú_DecodeUtf8EscapeErrors$   s   €ýür$   Úreturnc                 C   sF   t | tƒ}|r|r|  t¡S t| ƒS |r|  d¡} d dd„ | D ƒ¡S )am  Escape a bytes string for use in an text protocol buffer.

  Args:
    text: A byte string to be escaped.
    as_utf8: Specifies if result may contain non-ASCII characters.
        In Python 3 this allows unescaped non-ASCII Unicode characters.
        In Python 2 the return value will be valid UTF-8 rather than only ASCII.
  Returns:
    Escaped string (str).
  r   r   c                 S   s   g | ]}t | ‘qS r   )r"   )r   Úcr   r   r   Ú
<listcomp>J   s    zCEscape.<locals>.<listcomp>)Ú
isinstanceÚstrr   r   r$   ÚencodeÚjoin)ÚtextZas_utf8Ztext_is_unicoder   r   r   ÚCEscape1   s   


r-   z"(\\+)x([0-9a-fA-F])(?![0-9a-fA-F])r,   c                 C   s>   dd„ }t  || ¡}| d¡ d¡}| d¡ d¡}| d¡S )z”Unescape a text string with C-style escape sequences to UTF-8 bytes.

  Args:
    text: The data to parse in a str.
  Returns:
    A byte string.
  c                 S   s4   t |  d¡ƒd@ r|  d¡d |  d¡ S |  d¡S )Nr   Zx0é   r   )ÚlenÚgroup)Úmr   r   r   Ú
ReplaceHexY   s   
zCUnescape.<locals>.ReplaceHexZraw_unicode_escaper   Úunicode_escapezlatin-1)Ú_CUNESCAPE_HEXÚsubr*   r   )r,   r2   Úresultr   r   r   Ú	CUnescapeP   s
   		
r7   )Ú__doc__Úrer   r   r   r   r"   Úupdater$   r)   r-   Úcompiler4   Úbytesr7   r   r   r   r   Ú<module>   s   

