fix for a bug reported by Kirill (unknown charset '8859-1')

This commit is contained in:
Miroslav Stampar 2011-03-24 09:27:19 +00:00
parent d79fae724c
commit 762397854e

View File

@ -101,11 +101,15 @@ def checkCharEncoding(encoding):
if delimiter in encoding: if delimiter in encoding:
encoding = encoding[:encoding.find(delimiter)] encoding = encoding[:encoding.find(delimiter)]
# popular typos/errors
if '8858' in encoding:
encoding = encoding.replace('8858', '8859')
if encoding.startswith('8859'):
encoding = 'iso-%s' % encoding
# http://philip.html5.org/data/charsets-2.html # http://philip.html5.org/data/charsets-2.html
if encoding in translate: if encoding in translate:
encoding = translate[encoding] encoding = translate[encoding]
elif encoding.startswith('iso-8858'): #very popular typo
encoding = encoding.replace('8858', '8859')
elif encoding.startswith('cp-'): elif encoding.startswith('cp-'):
encoding = 'cp%s' % encoding[3:] encoding = 'cp%s' % encoding[3:]
elif encoding.startswith('windows') and not encoding.startswith('windows-'): elif encoding.startswith('windows') and not encoding.startswith('windows-'):