summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Li <andy@onthewings.net>2012-12-08 00:28:44 +0800
committerAndy Li <andy@onthewings.net>2012-12-08 00:28:44 +0800
commit01f0085bada41394198bd7ac753f280a516675da (patch)
tree7bc0ef99abde47c02409e69032e8d47cfa72543a
parentf56dfa92ab78b1834677b84a9b2f21c3e1eb5a52 (diff)
downloadpygments-01f0085bada41394198bd7ac753f280a516675da.tar.gz
fixed #822 (remove BOM if present)
-rw-r--r--pygments/lexer.py1
-rw-r--r--tests/test_examplefiles.py1
2 files changed, 2 insertions, 0 deletions
diff --git a/pygments/lexer.py b/pygments/lexer.py
index ad2c72d1..6f466a77 100644
--- a/pygments/lexer.py
+++ b/pygments/lexer.py
@@ -164,6 +164,7 @@ class Lexer(object):
else:
text = text.decode(self.encoding)
# text now *is* a unicode string
+ text = text.lstrip(u'\xef\xbb\xbf\ufeff') # remove BOM
text = text.replace('\r\n', '\n')
text = text.replace('\r', '\n')
if self.stripall:
diff --git a/tests/test_examplefiles.py b/tests/test_examplefiles.py
index 41acf4ef..1d3515df 100644
--- a/tests/test_examplefiles.py
+++ b/tests/test_examplefiles.py
@@ -54,6 +54,7 @@ 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: