[PATCH] highlight: pass hgweb.encoding to lexers and formatter

Matt Mackall mpm at selenic.com
Tue Dec 11 15:50:00 CST 2007


On Tue, Dec 11, 2007 at 10:21:23PM +0100, Christian Ebert wrote:
> Hello,
> 
> The following is needed to avoid a nasty backtrace when a file
> contains non-ascii characters.
> 
> Should perhaps be tested in non-utf locale; also I am not
> entirely sure if the lexers should get passed util._encoding.
> Anyway this gave consistent results re encoding with highlight
> turned on and off.

Ugh. Apps should assume that regardless of what encoding they're in,
someone's going to throw them a byte that can't be decoded. If it was
throwing an exception when it was assuming ASCII, it will still throw
exceptions when you try to pass off Latin-1 as UTF-8 or whatever. So
this fix is insufficient.

Odds are good that pygments is hopelessly infected with Unicode
braindamage, so I somehow doubt there -is- a good fix.

-- 
Mathematics is the supreme nostalgia of our time.


More information about the Mercurial-devel mailing list