<div dir="ltr"><div>I already have a solution in Python 3 (see <a href="https://github.com/Drekin/win-unicode-console">https://github.com/Drekin/win-unicode-console</a>, <a href="https://pypi.python.org/pypi/win_unicode_console">https://pypi.python.org/pypi/win_unicode_console</a>), I was just considering adding support for Python 2 as well. I think I have an working example in Python 2 using ctypes.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 7, 2015 at 9:23 PM, "Martin v. Löwis" <span dir="ltr"><<a href="mailto:martin@v.loewis.de" target="_blank">martin@v.loewis.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Am 02.05.15 um 21:57 schrieb Adam Bartoš:<br>
<span class="">> Even if sys.stdin contained a file-like object with proper encoding<br>
> attribute, it wouldn't work since sys.stdin has to be instance of <type<br>
> 'file'>. So the question is, whether it is possible to make a file instance<br>
> in Python that is also customizable so it may call my code. For the first<br>
> thing, how to change the value of encoding attribute of a file object.<br>
<br>
</span>If, by "in Python", you mean both "in pure Python", and "in Python 2",<br>
then the answer is no. If you can add arbitrary C code, then you might<br>
be able to hack your C library's stdio implementation to delegate fread<br>
calls to your code.<br>
<br>
I recommend to use Python 3 instead.<br>
<br>
Regards,<br>
Martin<br>
<br>
</blockquote></div><br></div>