Fix encoding problems with creation of TOC for recipes

This commit is contained in:
Kovid Goyal 2008-05-18 09:56:26 -07:00
parent be1dc747b5
commit efc0a61e70
2 changed files with 5 additions and 1 deletions

View File

@ -1,6 +1,7 @@
<ncx version="2005-1"
xml:lang="en"
xmlns="http://www.daisy.org/z3986/2005/ncx/"
encoding="UTF-8"
xmlns:py="http://genshi.edgewall.org/"
>
<head>

View File

@ -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)