mirror of
git://github.com/kovidgoyal/calibre.git
synced 2025-12-22 00:34:48 +01:00
Make xml_to_unicode robust against chardet failing.
This commit is contained in:
parent
147c5d7711
commit
c73315bb51
1 changed files with 4 additions and 0 deletions
|
|
@ -15,6 +15,7 @@
|
|||
# 02110-1301 USA
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
|
||||
__version__ = "1.0"
|
||||
|
||||
import re
|
||||
|
|
@ -55,6 +56,9 @@ def xml_to_unicode(raw, verbose=False):
|
|||
print 'WARNING: Encoding detection confidence %d%%'%(chardet['confidence']*100)
|
||||
CHARSET_ALIASES = { "macintosh" : "mac-roman",
|
||||
"x-sjis" : "shift-jis" }
|
||||
if not encoding:
|
||||
from calibre import preferred_encoding
|
||||
encoding = preferred_encoding
|
||||
if encoding:
|
||||
encoding = encoding.lower()
|
||||
if CHARSET_ALIASES.has_key(encoding):
|
||||
|
|
|
|||
Loading…
Reference in a new issue