[PATCH] windows: switch the console encoding into an encoding actually used (issue2926)

Adrian Buehlmann adrian at cadifra.com
Fri Jul 29 00:00:57 UTC 2011


On 2011-07-29 01:26, Andrei Polushin wrote:
> 29.07.2011 5:53, Adrian Buehlmann wrote:
>> Is there a reason why this can't be done by using Python's ctypes
>> instead of C code? (see win32.py)
> 
> The only reason was that I'm a C++ programmer, not a Python programmer
> (yet). I didn't know about ctypes.

I wrote quite some C++ as well. Mostly for Windows. Because of
Mercurial, I got started a bit deeper into Python.

> Probably, I need help to do it in a non-natural way. Is it worth the effort?
> Looks like Mercurial already has plaform-specific C code anyway.
> 
> I plan to leave C code in osutil.c and call it from the windows-specific
> extension. Could it be done this way?

It could, but for newer things we prefer not adding C code just to call
a few Windows API's. Mercurial on Windows now depends on ctypes.

I could help you by adding basic infrastructure in win32.py. It's not
that difficult. You could then call that in your extension.

Or you can use ctypes right in your extension. For example, the color
extension which is maintained by the Mercurial project uses ctypes too
[1]. I could help you doing that as well.

In case you're interested about the details how to use ctypes:
http://docs.python.org/library/ctypes.html

[1] http://selenic.com/repo/hg/file/a5046880eca3/hgext/color.py#l378


More information about the Mercurial-devel mailing list