Special characters in commit message on command line

Matt Mackall mpm at selenic.com
Mon Jun 20 09:15:08 CDT 2011


On Mon, 2011-06-20 at 13:41 +0200, Sune Foldager wrote:
> On 2011-06-17 13:48, Matt Mackall wrote:
> >On Fri, 2011-06-17 at 13:42 -0500, Robert Altman wrote:
> >> Is there any way to enter special characters in a commit message when typing
> >> at the command line?
> >>
> >> For example:
> >> hg commit -m"Too many changes to describe!"
> >> hg commit -m"Changes 'mebabytes' to megabytes'"
> >
> >On Windows, this will be hard. The console and the GUI (ie where your
> >usual commit editor lives) don't agree about how to encode characters,
> >so Mercurial goes by the _GUI's_ idea of the current encoding.
> 
> Depends... notepad defaults to the system charset, and the console does
> as well. So as long as the characters are in that charset it's ok.

That's usually NOT the case. For instance, in the US, the console uses
cp437 which is essentially the hardware font on the original IBM PC for
compatibility with ancient DOS apps:

https://secure.wikimedia.org/wikipedia/en/wiki/Code_page_437

Whereas the GUI (and notepad) use cp1252, which is a bastardized version
of ISO 8859-1:

https://secure.wikimedia.org/wikipedia/en/wiki/Windows-1252

..and there is NO overlap of codepoints between these two outside of the
ASCII subset.


On these systems, when you're running Mercurial in the console (cp437),
Mercurial ignores that and uses the OTHER encoding (cp1252) exclusively
for compatibility with the GUI side of things. So if you attempt to pass
non-ASCII chacters in the console codepage (ó -> 0xA2 in cp437) to it on
the command line, you will fail (0xA2 -> ¢ in cp1252).

You can use "chcp cp1252" in the console to make the two agree, in which
case everything should work fine.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial mailing list