How do I specify the source file encoding?

Christian Boos cboos at neuf.fr
Thu Feb 12 00:53:23 CST 2009


Alexandr N Zamaraev wrote:
> Matt Mackall пишет:
>   
>> On Wed, 2009-02-11 at 14:48 +0600, Alexandr N Zamaraev wrote:
>>     
>>> How do I specify the source file encoding?
>>>       
>> Mercurial intentionally doesn't track encoding.
>>     
>>> This is necessary to Trac to display it correctly.
>>>       
>> You should take that up with whoever it is that manages the Mercurial
>> plug-in for Trac.
>>     
> Mercurial is not required to maintain the properties of Trac, but any 
> mechanism to specify the source encoding it should be.
> Otherwise, how correctly to show the source through the web?
>   

This will be handled at the Trac level, please see 
http://trac.edgewall.org/ticket/7160

There's one thing though which is possible in systems like Subversion 
and which is hard to do at the Mercurial level is that you can set the 
encoding on a file by file basis, if you really want to. The "Mercurial 
way" for such a thing would be to have some sort of .hgencoding file, 
which would map file patterns to encoding names. Or alternatively, a 
.hgmimetypes file that would map file patterns to both mime-types and 
encodings, like the svn:mime-type property does in svn. Such additional 
metadata would be useful for external tools like Trac, but maybe also 
for hgweb, for things like highlighting or recoding from the original 
encoding to utf-8 for proper display in web browsers. I'll eventually 
adopt such conventions at the Trac level, but maybe it makes sense to 
find some kind of broader convention that could benefit to a larger 
audience.

-- Christian



More information about the Mercurial mailing list