From cd17ac14d27b94b27f881a3b4a73e4e985d984b8 Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Sat, 5 Mar 2022 21:28:05 -0500 Subject: fix more UTF-8 errors --- mbbmlib.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'mbbmlib.py') diff --git a/mbbmlib.py b/mbbmlib.py index 8b8d585..0d000ef 100644 --- a/mbbmlib.py +++ b/mbbmlib.py @@ -6,6 +6,7 @@ # Title: Export Firefox Bookmarks to Html # Purpose: Add favicons to bookmarks in exported html file # History: +# 2022-03-05 fix even more UTF-8 crap # Usage: # main command is export_bookmarks_to_html. # Reference: @@ -16,6 +17,7 @@ # https://stackoverflow.com/questions/43446353/converting-png-images-to-base64 # future: https://stackoverflow.com/questions/5119041/how-can-i-get-a-web-sites-favicon # https://rosettacode.org/wiki/Strip_control_codes_and_extended_characters_from_a_string#Python +# conn.text_factory to fix UTF-8 crap https://stackoverflow.com/questions/22751363/sqlite3-operationalerror-could-not-decode-to-utf-8-column/58891189#58891189 # Improve: # add to pretty_print the option to select what format the output is in, like "title | url | icon" or similar. # Documentation: @@ -299,6 +301,7 @@ class Bookmark: if debuglev > 4: print("Using places file {0} and icons_file {1}".format(places_file,icons_file)) with sqlite3.connect(places_file) as conn: + conn.text_factory = lambda b: b.decode(errors = 'ignore') # detect browser automatically if browser == 'autodetect': -- cgit