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

Matt Mackall mpm at selenic.com
Thu Jul 28 16:20:26 CDT 2011


On Fri, 2011-07-29 at 03:52 +0700, Andrei Polushin wrote:
> # HG changeset patch
> # User Andrei Polushin <polushin at gmail.com>
> # Date 1311886282 -25200
> # Branch stable
> # Node ID 61ace80f43d6144bef600d7ebe05f75f80fd0fe3
> # Parent  56848e2bb0c5a43b580dd2ca7ce1e781d4e75b2b
> windows: switch the console encoding into an encoding actually used (issue2926)
> 
> The encoding of the console is switched temporarily, for the time the Mercurial
> is running, and restored to the previous value on exit.

A very interesting solution! It is also 'magic' in the sense that a
knowledgeable user will be surprised by this behavior, so it might be
something we'd want to stick in an extension.

> This solution is backward compatible, it changes almost nothing, i.e. neither
> stdout/pipe encoding, nor internal string handling are affected anyway.
> 
> One problem still remains: `hg log | more' doesn't produce readable output on
> OEM console, I've found no way to change the console encoding when redirected.

Hmm, is the notion of current codepage attached to the Mercurial process
and not to the console then? Is this code doing something different than
chcp?

As a test, can you instead do an 'os.system("chcp ...")' in the hg
startup?

Also, curious: do a chcp change the appearance of non-ASCII characters
currently displayed in the console?

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list