summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bs4/dammit.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/bs4/dammit.py b/bs4/dammit.py
index 8e6b347..317ad6d 100644
--- a/bs4/dammit.py
+++ b/bs4/dammit.py
@@ -272,6 +272,9 @@ class EncodingDetector:
def strip_byte_order_mark(cls, data):
"""If a byte-order mark is present, strip it and return the encoding it implies."""
encoding = None
+ if isinstance(data, unicode):
+ # Unicode data cannot have a byte-order mark.
+ return data, encoding
if (len(data) >= 4) and (data[:2] == b'\xfe\xff') \
and (data[2:4] != '\x00\x00'):
encoding = 'utf-16be'