diff --git a/src/calibre/ebooks/metadata/ncx.xml b/src/calibre/ebooks/metadata/ncx.xml index 7bcb9ac479..68971f63f1 100644 --- a/src/calibre/ebooks/metadata/ncx.xml +++ b/src/calibre/ebooks/metadata/ncx.xml @@ -1,6 +1,7 @@ diff --git a/src/calibre/ebooks/metadata/toc.py b/src/calibre/ebooks/metadata/toc.py index df668fc49e..3caa23934b 100644 --- a/src/calibre/ebooks/metadata/toc.py +++ b/src/calibre/ebooks/metadata/toc.py @@ -7,6 +7,7 @@ from urllib import unquote from calibre import __appname__ from calibre.ebooks.BeautifulSoup import BeautifulStoneSoup, BeautifulSoup +from calibre.ebooks.chardet import xml_to_unicode class NCXSoup(BeautifulStoneSoup): @@ -95,7 +96,9 @@ class TOC(list): def read_ncx_toc(self, toc): self.base_path = os.path.dirname(toc) - soup = NCXSoup(open(toc, 'rb').read()) + print xml_to_unicode(open(toc, 'rb').read(), True)[1] + soup = NCXSoup(xml_to_unicode(open(toc, 'rb').read())[0]) + print unicode(soup).encode('utf8') def process_navpoint(np, dest): play_order = np.get('playOrder', 1)