diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2012-05-14 21:15:32 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2012-05-14 21:15:32 -0400 |
commit | 65ae23a8fe1b8e5740431497331fecfbd3c8b3fd (patch) | |
tree | 8c04959873026f9c52074afda7fbdb7c927e7421 /coverage/html.py | |
parent | a652c8f79097392c46ed51760ead2499fa61b45d (diff) | |
download | python-coveragepy-git-65ae23a8fe1b8e5740431497331fecfbd3c8b3fd.tar.gz |
Properly deal with files encoded as UTF-8 with BOM. Fixes #179.
Diffstat (limited to 'coverage/html.py')
-rw-r--r-- | coverage/html.py | 4 |
1 files changed, 4 insertions, 0 deletions
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 |