This commit is contained in:
Kovid Goyal 2011-01-07 18:18:43 -07:00
parent 5f2b49f88a
commit 3f30de95a3
4 changed files with 6 additions and 2 deletions

View File

@ -977,6 +977,8 @@ def create_oebbook(log, path_or_stream, opts, input_plugin, reader=None,
from calibre.ebooks.oeb.base import OEBBook from calibre.ebooks.oeb.base import OEBBook
html_preprocessor = HTMLPreProcessor(input_plugin.preprocess_html, html_preprocessor = HTMLPreProcessor(input_plugin.preprocess_html,
opts.preprocess_html, opts) opts.preprocess_html, opts)
if not encoding:
encoding = None
oeb = OEBBook(log, html_preprocessor, oeb = OEBBook(log, html_preprocessor,
pretty_print=opts.pretty_print, input_encoding=encoding) pretty_print=opts.pretty_print, input_encoding=encoding)
if not populate: if not populate:

View File

@ -119,7 +119,7 @@ class HTMLFile(object):
self.is_binary = level > 0 and not bool(self.HTML_PAT.search(src[:4096])) self.is_binary = level > 0 and not bool(self.HTML_PAT.search(src[:4096]))
if not self.is_binary: if not self.is_binary:
if encoding is None: if not encoding:
encoding = xml_to_unicode(src[:4096], verbose=verbose)[-1] encoding = xml_to_unicode(src[:4096], verbose=verbose)[-1]
self.encoding = encoding self.encoding = encoding
else: else:

View File

@ -139,7 +139,7 @@ class BookHeader(object):
65001: 'utf-8', 65001: 'utf-8',
}[self.codepage] }[self.codepage]
except (IndexError, KeyError): except (IndexError, KeyError):
self.codec = 'cp1252' if user_encoding is None else user_encoding self.codec = 'cp1252' if not user_encoding else user_encoding
log.warn('Unknown codepage %d. Assuming %s' % (self.codepage, log.warn('Unknown codepage %d. Assuming %s' % (self.codepage,
self.codec)) self.codec))
if ident == 'TEXTREAD' or self.length < 0xE4 or 0xE8 < self.length \ if ident == 'TEXTREAD' or self.length < 0xE4 or 0xE8 < self.length \

View File

@ -146,6 +146,8 @@ class Widget(QWidget):
codecs.lookup(ans) codecs.lookup(ans)
except: except:
ans = '' ans = ''
if not ans:
ans = None
return ans return ans
elif isinstance(g, QComboBox): elif isinstance(g, QComboBox):
return unicode(g.currentText()) return unicode(g.currentText())