summaryrefslogtreecommitdiff
path: root/tests/test_examplefiles.py
diff options
context:
space:
mode:
authorAndy Li <andy@onthewings.net>2012-12-12 18:11:34 +0800
committerAndy Li <andy@onthewings.net>2012-12-12 18:11:34 +0800
commita0fb320fd7264c3804fd846277f47d40b9013282 (patch)
tree72f3db02e15c2e5dbc3f80469f2351134c9ddfb8 /tests/test_examplefiles.py
parentd523209a898076e118144e6260de6bdb1778c1a4 (diff)
downloadpygments-a0fb320fd7264c3804fd846277f47d40b9013282.tar.gz
Remove BOM when the input is unicode.
Diffstat (limited to 'tests/test_examplefiles.py')
-rw-r--r--tests/test_examplefiles.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/tests/test_examplefiles.py b/tests/test_examplefiles.py
index 1d3515df..a938ebaa 100644
--- a/tests/test_examplefiles.py
+++ b/tests/test_examplefiles.py
@@ -54,11 +54,12 @@ def check_lexer(lx, absfn, outfn):
text = fp.read()
finally:
fp.close()
- text = text.lstrip(u'\xef\xbb\xbf\ufeff') #remove BOM
text = text.replace(b('\r\n'), b('\n'))
text = text.strip(b('\n')) + b('\n')
try:
text = text.decode('utf-8')
+ if text.startswith(u'\ufeff'):
+ text = text[len(u'\ufeff'):]
except UnicodeError:
text = text.decode('latin1')
ntext = []