+
    ¿Ìjµ  ã                   ó,  € R t ^ RIHt ^ RIt^ RIt^ RIt^ RIHt ]P                  P                  ^8¬  t
]
'       d   ^ RIHt M^ RIHt RtRtRt ]! 4       tR tR
R	 ltR#   ] d,   t]'       d   ]! RP-                  ]4      4       Rt RtAL7RtAii ; i)a  
Tool to help with input/output encoding

Helpers to run smoothly in unicode-unfriendly environments like output redirect
or unusual language settings.

In such settings, output to console falls back to ASCII-only. Also open()
suddenly fails to interprete non-ASCII characters.

Therefore, at start of scripts can run :py:meth:`ensure_stdout_handles_unicode`
and when opening text files use :py:meth:`uopen` to replace :py:meth:`open`.

Part of the python-oletools package:
http://www.decalage.info/python/oletools
)Úprint_functionN)Úgetpreferredencoding)ÚopenÚutf8Fz(Exception getting preferred encoding: {}c                 ó  € \        \        P                  \        P                  4      '       d   \
        '       d   \        R4       R# \        '       d   \        P                  P                  p M\        P                  p  \        P                  P                  p\
        '       d   \        RP                  V4      4       \        V\        4      '       d?   VP                  4       P                  R4      '       d   \
        '       d   \        R4       R# \        P                   ! V P#                  4       4      '       dT   \        RP                  V4      \        P$                  R7       \        P&                  ! V4      ! V RR	7      \        n        R# \(        p\
        '       d   \        R
P                  V4      4       \        V\        4      '       d&   VP                  4       P                  R4      '       g-   \*        p\
        '       d   \        RP                  V4      4       \        RP                  W4      \        P$                  R7       \        P&                  ! V4      ! V 4      \        n        R#   \         d    Rp ELëi ; i)a(  
Ensure that print()ing unicode does not lead to errors.

When print()ing unicode, python relies on the environment (e.g. in linux on
the setting of the LANG environment variable) to tell it how to encode
unicode. That works nicely for modern-day shells where encoding is usually
UTF-8. But as soon as LANG is unset or just "C", or output is redirected or
piped, the encoding falls back to 'ASCII', which cannot handle unicode
characters.

Based on solutions suggested on stackoverflow (c.f.
https://stackoverflow.com/q/27347772/4405656 ), wrap stdout in an encoder
that solves that problem.

Unfortunately, stderr cannot be handled the same way ( see e.g. https://
pythonhosted.org/kitchen/unicode-frustrations.html#frustration-5-exceptions
), so we still have to hope there is only ascii in error messages
zsys.stdout wrapped alreadyNzsys.stdout encoding is {}Úutfzencoding is acceptablezOEncoding for stdout is only {}, will replace other chars to avoid unicode error)ÚfileÚreplace)Úerrorsz$not a tty, try preferred encoding {}z5preferred encoding also unacceptable, fall back to {}zKEncoding for stdout is only {}, will auto-encode text with {} before output)Ú
isinstanceÚsysÚstdoutÚcodecsÚStreamWriterÚDEBUGÚprintÚPY3ÚbufferÚencodingÚAttributeErrorÚformatÚstrÚlowerÚ
startswithÚosÚisattyÚfilenoÚstderrÚ	getwriterÚPREFERRED_ENCODINGÚFALLBACK_ENCODING_REDIRECT)Úoutput_streamr   Únew_encodings      Úu/home/l0st/web/w4ttz.lol/public_html/toolz/MsgDoxxer/venv/lib/python3.14/site-packages/oletools/common/io_encoding.pyÚensure_stdout_handles_unicoder$   U   s¯  € ô( ”#—*‘*œf×1Ñ1×2Ò2ß‹5ÜÐ.Ô/Ù÷ ƒsÜŸ
™
×)Ñ)‰äŸ
™
ˆðÜ—:‘:×&Ñ&ˆ÷ ƒuÜÐ)×0Ñ0°Ó:Ô;ä�(œC× Ò  X§^¡^Ó%5×%@Ñ%@À×%GÒ%Gß‹5ÜÐ*Ô+ÙÜ	�Š�=×'Ñ'Ó)×	*Ò	*ô 	ð $ß$*¡F¨8Ó$4¼3¿:¹:õ	Gä×%Ò% hÔ/°ÀiÔPŒŽ
ä)ˆß‹5ÜÐ8×?Ñ?ÀÓMÔNÜ˜,¬×,Ò,Ø#×)Ñ)Ó+×6Ñ6°u×=Ò=Ü5ˆLß‹uÜÐMß‘v˜lÓ+ô-äð ß$™f XÓ<Ä3Ç:Á:õ	Oä×%Ò% lÔ3°MÓBŒŽ
øô7 ô Ø‹ðús   Â I5 É5JÊJc                óž  € RV9   d'   \         '       d   \        R4       \        W.VO5/ VB # RV9   d=   \         '       d"   \        RP                  VR,          4      4       \        W.VO5/ VB # \	        V4      ^8”  d=   \         '       d"   \        RP                  V^,          4      4       \        W.VO5/ VB # \
        p\         '       d   \        RP                  V4      4       \        V\        4      '       d[   VP                  4       P                  R4      '       d6   \         '       d   \        RP                  V 4      4       \        W.VO5/ VB # \         '       d    \        RP                  V \        4      4       \        '       d   \        W.VO5R\        /VB # \        W.VO5/ VB p\        P                  ! V\        4      # )	aŸ  
Replacement for builtin open() that reads unicode even in ASCII environment

In order to read unicode from text, python uses locale.getpreferredencoding
to translate bytes to str. If the environment only provides ASCII encoding,
this will fail since most office files contain unicode.

Therefore, guess a good encoding here if necessary and open file with that.

:returns: same type as the builtin :py:func:`open`
Úbz%Opening binary file, do not interferer   z1Opening file with encoding {!r}, do not interferezpreferred encoding is {}r   z)encoding is acceptable, open {} regularlyz$Opening {} with fallback encoding {})r   r   Úbuiltin_openr   Úlenr   r   r   r   r   ÚFALLBACK_ENCODING_OPENr   r   ÚEncodedFile)ÚfilenameÚmodeÚargsÚkwargsr   Úhandles   &&*,  r#   Úuopenr0   •   s’  € ð ˆd„{ß‹5ÜÐ9Ô:Ü˜HÐ<¨TÒ<°VÑ<Ð<Ø�VÔß‹5ÜÐEß‘6˜& Õ,Ó-ô/ä˜HÐ<¨TÒ<°VÑ<Ð<Ü
ˆ4ƒy�1„}ß‹5ÜÐEß‘6˜$˜q�'“?ô$ä˜HÐ<¨TÒ<°VÑ<Ð<ô "€HßƒuÜÐ(×/Ñ/°Ó9Ô:ä�(œC× Ò  X§^¡^Ó%5×%@Ñ%@À×%GÒ%Gß‹5ÜÐ=×DÑDÀXÓNÔOÜ˜HÐ<¨TÒ<°VÑ<Ð<÷ ƒuÜÐ4ß‰v�hÔ 6Ó7ô	9ç
ƒsÜ˜Hð G¨Tò GÜ%;ðGØ?EñGð 	Gô ˜hÐ>¨tÒ>°vÑ>ˆÜ×!Ò! &Ô*@ÓAÐAó    )Úr)Ú__doc__Ú
__future__r   r   r   r   Úlocaler   Úversion_infoÚmajorr   Úbuiltinsr   r'   Ú__builtin__r    r)   r   r   Ú	ExceptionÚexcr   r   r$   r0   © r1   r#   Ú<module>r=      s�   ðñõ^ &Û 
Û Û 	Ý 'à	×Ñ×Ñ Ñ!€çÞ-å0ð $Ð ð  Ð ð 	€ðÙ-Ó/Ðò=Cö@0BøðS ô ßÙÐ8×?Ñ?ÀÓDÔEØÕûðús   ÁA! Á!BÁ(!BÂB