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 | d31a41bfd035a537fd91e894805f411d17033847 (patch) | |
tree | 55b65a9b9edeaa156541686abf6a326ce324d867 /coverage/html.py | |
parent | baafb94e9cb5aec5ced0cd6e087d0c6c51e4c785 (diff) | |
download | python-coveragepy-d31a41bfd035a537fd91e894805f411d17033847.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 f39bf94..b0eff5f 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 |