Python library to interact with EPUB files.
sakolkar / openepub Goto Github PK
View Code? Open in Web Editor NEWPython library to interact with EPUB files.
License: The Unlicense
Python library to interact with EPUB files.
License: The Unlicense
Affects versions
<=0.0.6
When performing path.read_text()
through the zipfile
standard library a UnicodeDecodeError
is raised. The zipfile library uses io.text_encoding()
which seems to return locale
most of the time. On Windows, this locale
encoding turns into cp1252
which works sometimes for decoding the .opf
file. But for languages like Japanese, oftentimes there are characters not in the cp1252
character set.
Eg.
>>> c[460:500].decode("utf8")
' id="author_0">Hakuchō Masamune</dc:cre'
>>> c[460:500].decode("cp1252", "replace")
' id="author_0">Hakuch� Masamune</dc:cre'
This leads to an error like this:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/usr/lib/python3.10/encodings/cp1252.py", line 15, in decode
return codecs.charmap_decode(input,errors,decoding_table)
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 482: character maps to <undefined>
Specify encoding utf-8
so that on Windows it doesn't default into using cp1252
.
Hey there!
In issue LuteOrg/lute-v3#344, there's an image showing how spaces are getting stripped during epub import. e.g., Here's a screenshot of the source epub:
Here's how it appears in Lute:
Here's the actual source in the zipped epub html:
<p class="Clanek1"><span lang="CS">Odpovědi na tyto a mnohé další otázky hledá v novém senzačním životopise
nazvaném </span><span lang="CS" class="calibre8">Život a lži Albuse Brumbála</span><span lang="CS"> Rita Holoubková. Exkluzivní rozhovor s ní přináší Betty Braithwaiteová
na straně 13.</span></p>
Ideally, the above snippet would be extracted as:
Odpovědi na tyto a mnohé další otázky hledá v novém senzačním životopise nazvaném Život a lži Albuse Brumbála Rita Holoubková. Exkluzivní rozhovor s ní přináší Betty Braithwaiteová na straně 13.
Does this seem like it's possible? Cheers!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.