mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix to MOBI 'Unknown' problem (replacing all empty strings with the string Unknown)
This commit is contained in:
parent
e6a1a39597
commit
0c25a25eb4
@ -302,7 +302,7 @@ def encode_tbs(val, extra, flag_size=4):
|
|||||||
ans += encint(extra[0b0001])
|
ans += encint(extra[0b0001])
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
def utf8_text(text):
|
def utf8_text(text, empty=False):
|
||||||
'''
|
'''
|
||||||
Convert a possibly null string to utf-8 bytes, guaranteeing to return a non
|
Convert a possibly null string to utf-8 bytes, guaranteeing to return a non
|
||||||
empty, normalized bytestring.
|
empty, normalized bytestring.
|
||||||
@ -313,7 +313,10 @@ def utf8_text(text):
|
|||||||
text = text.decode('utf-8', 'replace')
|
text = text.decode('utf-8', 'replace')
|
||||||
text = normalize(text).encode('utf-8')
|
text = normalize(text).encode('utf-8')
|
||||||
else:
|
else:
|
||||||
|
if not empty:
|
||||||
text = _('Unknown').encode('utf-8')
|
text = _('Unknown').encode('utf-8')
|
||||||
|
else:
|
||||||
|
text = u''.encode('utf-8') # yeah, stupid
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def align_block(raw, multiple=4, pad=b'\0'):
|
def align_block(raw, multiple=4, pad=b'\0'):
|
||||||
|
@ -355,7 +355,7 @@ class Serializer(object):
|
|||||||
text = text.replace(u'\u00AD', '') # Soft-hyphen
|
text = text.replace(u'\u00AD', '') # Soft-hyphen
|
||||||
if quot:
|
if quot:
|
||||||
text = text.replace('"', '"')
|
text = text.replace('"', '"')
|
||||||
self.buf.write(utf8_text(text))
|
self.buf.write(utf8_text(text, empty=True))
|
||||||
|
|
||||||
def fixup_links(self):
|
def fixup_links(self):
|
||||||
'''
|
'''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user