From 65ae23a8fe1b8e5740431497331fecfbd3c8b3fd Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 14 May 2012 21:15:32 -0400 Subject: Properly deal with files encoded as UTF-8 with BOM. Fixes #179. --- coverage/html.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'coverage/html.py') diff --git a/coverage/html.py b/coverage/html.py index f39bf949..b0eff5f2 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -148,6 +148,10 @@ class HtmlReporter(Reporter): # later to properly write the HTML. if sys.version_info < (3, 0): encoding = source_encoding(source) + # Some UTF8 files have the dreaded UTF8 BOM. If so, junk it. + if encoding.startswith("utf-8") and source[:3] == "\xef\xbb\xbf": + source = source[3:] + encoding = "utf-8" # Get the numbers for this file. nums = analysis.numbers -- cgit v1.2.1