This commit is contained in:
Kovid Goyal 2012-03-26 14:17:45 +05:30
parent 3235ca7356
commit 163f82a046

View File

@ -58,10 +58,10 @@ def parse_indx_header(data):
# This appears to be EBCDIC-UTF (65002) encoded. I can't be # This appears to be EBCDIC-UTF (65002) encoded. I can't be
# bothered to write a decoder for this (see # bothered to write a decoder for this (see
# http://www.unicode.org/reports/tr16/) Just how stupid is Amazon? # http://www.unicode.org/reports/tr16/) Just how stupid is Amazon?
# Instead I use a half assed decoder that decodes only the ascii # Instead, we use a weird hack that seems to do the trick for all
# valid values correctly. Hopefully these ORDT sections will only # the books with this type of ORDT record that I have come across.
# ever be used in SKEL and ELEM indices where the text is pure # Basically we try to interpret every second byte as a printable
# ASCII. Any non ASCII valid values are mapped to the ? character. # ascii character. If we cannot, we map to the ? char.
parsed = bytearray(ans['oentries']) parsed = bytearray(ans['oentries'])
for i in xrange(0, 2*ans['oentries'], 2): for i in xrange(0, 2*ans['oentries'], 2):