]> git.phdru.name Git - bookmarks_db.git/commitdiff
Fix(Py3): Always open text storage files in UTF-8
authorOleg Broytman <phd@phdru.name>
Tue, 21 Nov 2023 18:46:42 +0000 (21:46 +0300)
committerOleg Broytman <phd@phdru.name>
Tue, 21 Nov 2023 18:46:42 +0000 (21:46 +0300)
Storage/bkmk_stflad.py
Storage/bkmk_stjson.py
Storage/debug-json/pprint-json.py

index 7a29b83cd1c76b5f03faefa2decb0897a06d6efb..81a4e6dc38e025c36ab2981737504efdeac42311 100644 (file)
@@ -25,7 +25,7 @@ class storage_flad(Walker):
     def root_folder(self, f):
         header = f.header.replace(".", ".\n")
         header = header.replace("<", "\n<", 3)[1:]
-        header_file = open("header", 'wt')
+        header_file = open("header", 'wt', encoding='utf-8')
         header_file.write(header + "\n")
         header_file.write('<H1>%s</H1>\n\n' % f.name)
         if f.comment: header_file.write('<DD>%s\n' % f.comment)
@@ -61,7 +61,7 @@ Charset: %s
         self.outfile.write("\nLevel: %s\nRuler: YES\n" % (level+1))
 
     def store(self, root_folder):
-        self.outfile = open(self.filename, 'wt')
+        self.outfile = open(self.filename, 'wt', encoding='utf-8')
         root_folder.walk_depth(self)
         self.outfile.close()
 
@@ -83,7 +83,7 @@ Charset: %s
         self.folder_stack = [root_folder]
         self.current_folder = root_folder
 
-        header_file = open("header", 'rt')
+        header_file = open("header", 'rt', encoding='utf-8')
         header = header_file.read()
         header_file.close()
 
index 9f7fed78202d319658aa199047069f979a8c18e0..1d32fdc8af03de294ecc1eab4bad1f1a78ffaf10 100644 (file)
@@ -91,13 +91,13 @@ class storage_json(Walker):
     def store(self, root_folder):
         root_folder.walk_depth(self)
 
-        outfile = open(self.filename, 'wt')
+        outfile = open(self.filename, 'wt', encoding='utf-8')
         json.dump(self.dict, outfile)
         outfile.close()
         del self.dict
 
     def load(self):
-        infile = open(self.filename, 'rt')
+        infile = open(self.filename, 'rt', encoding='utf-8')
         bkmk_s = infile.read()
         infile.close()
 
index b90f9f057ab80a88d7cc01b9e4f0881e52798bef..6b9d28056172a3f446b237c679edef06e1dd3ce1 100755 (executable)
@@ -4,7 +4,7 @@ import sys
 import json
 from pprint import pprint
 
-infile = open(sys.argv[1], 'rt')
+infile = open(sys.argv[1], 'rt', encoding='utf-8')
 bkmk_s = infile.read()
 infile.close()