Fix JSON related encoding issue

master
pictuga 2013-12-04 20:26:39 +01:00
parent c43bf9f35f
commit e3f525ff2a
1 changed files with 3 additions and 1 deletions

View File

@ -51,7 +51,9 @@ def parse(data):
match = re.search('encoding=["\']?([0-9a-zA-Z-]+)', data[:100]) match = re.search('encoding=["\']?([0-9a-zA-Z-]+)', data[:100])
if match: if match:
enc = match.groups()[0].lower() enc = match.groups()[0].lower()
data = data.decode(enc, 'ignore').encode(enc) if not isinstance(data, unicode):
data = data.decode(enc, 'ignore')
data = data.encode(enc)
# parse # parse
parser = etree.XMLParser(recover=True) parser = etree.XMLParser(recover=True)