diff --git a/src/calibre/ebooks/txt/txtml.py b/src/calibre/ebooks/txt/txtml.py index 12506c1b33..73bdeb8a81 100644 --- a/src/calibre/ebooks/txt/txtml.py +++ b/src/calibre/ebooks/txt/txtml.py @@ -97,7 +97,13 @@ class TXTMLizer: if getattr(self.opts, 'inline_toc', None): self.log.debug('Generating table of contents...') toc.append('{}\n\n'.format(_('Table of Contents:'))) + unihandecoder = None + if getattr(self.opts, 'asciiize', False): + from calibre.utils.localization import get_udc + unihandecoder = get_udc() for item in self.toc_titles: + if unihandecoder is not None: + item = unihandecoder.decode(item) toc.append(f'* {item}\n\n') return ''.join(toc)