Quote:
Originally Posted by jackie_w
At the risk of me trying to "teach Granny how to suck eggs"  ...
When I was migrating my own plugins to python3 I found these 2 items from polyglot.builtins very useful: as_unicode, as_bytes
After I'd finished I don't think I had any .encode(...) or .decode(...) code left to go wrong. However, (full disclosure) I only ever use calibre's current container class to do everything related to epub-wrangling, so it's quite likely Kovid has already catered for everything that's likely to go wrong encoding-wise.
|
Thanks, but the problem arises elsewhere. The 'etree' package does strange things with encoding, returning byte strings sometimes and unicode other times. Same thing is true when opening files: now sometimes you need 'rb' and sometimes 'r', and sometimes the "newline=" argument. The code made no provision for getting images vs text. And so on.
Also, the plugin has a reimplemented container. I tried to go back to calibre's but that opened more cans than I could handle.