U
    ýÇ-e  ã                   @   s:   d Z ddlZddlZddlZddd„Zd	dd„Zeƒ ZdS )
z+
Utilities for dealing with text encodings
é    Nc                 C   s   t | dƒr| js|S | jS dS )a)  Return the given stream's encoding or a default.

    There are cases where ``sys.std*`` might not actually be a stream, so
    check for the encoding attribute prior to returning it, and return
    a default if it doesn't exist or evaluates as False. ``default``
    is None if not provided.
    ÚencodingN)Úhasattrr   )ÚstreamÚdefault© r   úW/var/www/html/Darija-Ai-Train/env/lib/python3.8/site-packages/IPython/utils/encoding.pyÚget_stream_enc   s    r   Tc                 C   sh   d}| rt tjƒ}|r|dkr@zt ¡ }W n tk
r>   Y nX |pJt ¡ }|dkrdt dt	¡ dS |S )aÛ  Return IPython's guess for the default encoding for bytes as text.

    If prefer_stream is True (default), asks for stdin.encoding first,
    to match the calling Terminal, but that is often None for subprocesses.

    Then fall back on locale.getpreferredencoding(),
    which should be a sensible platform default (that respects LANG environment),
    and finally to sys.getdefaultencoding() which is the most conservative option,
    and usually UTF8 as of Python 3.
    NÚasciiZcp0zˆInvalid code page cp0 detected - using cp1252 instead.If cp1252 is incorrect please ensure a valid code page is defined for the process.Úcp1252)
r   ÚsysÚstdinÚlocaleÚgetpreferredencodingÚ	ExceptionÚgetdefaultencodingÚwarningsÚwarnÚRuntimeWarning)Zprefer_streamÚencr   r   r   r   &   s     
ýr   )N)T)Ú__doc__r   r   r   r   r   ZDEFAULT_ENCODINGr   r   r   r   Ú<module>   s   

!