4040def _load_properties (path ):
4141 """Load a .properties file into an OrderedDict, preserving insertion order."""
4242 props = OrderedDict ()
43- with open (path ) as f :
43+ with open (path , encoding = "utf-8" ) as f :
4444 for line in f :
4545 line = line .strip ()
4646 if not line or line .startswith ("#" ):
@@ -70,7 +70,7 @@ def _find_with_extensions(directory, base_name):
7070
7171def _read_auto (path ):
7272 """Read a JSON or YAML file based on its extension."""
73- with open (path ) as f :
73+ with open (path , encoding = "utf-8" ) as f :
7474 if path .endswith (".yaml" ) or path .endswith (".yml" ):
7575 return yaml .safe_load (f )
7676 return json .load (f )
@@ -604,7 +604,7 @@ def build_locale(locale, templates, all_snippets):
604604 out_dir = os .path .join (SITE_DIR , locale , snippet ["category" ])
605605 os .makedirs (out_dir , exist_ok = True )
606606 out_path = os .path .join (out_dir , f"{ snippet ['slug' ]} .html" )
607- with open (out_path , "w" , newline = "" ) as f :
607+ with open (out_path , "w" , newline = "" , encoding = "utf-8" ) as f :
608608 f .write (html_content )
609609
610610 print (f"Generated { len (all_snippets )} HTML files for { locale } " )
@@ -622,7 +622,7 @@ def build_locale(locale, templates, all_snippets):
622622 else os .path .join (SITE_DIR , locale , "data" )
623623 )
624624 os .makedirs (data_dir , exist_ok = True )
625- with open (os .path .join (data_dir , "snippets.json" ), "w" ) as f :
625+ with open (os .path .join (data_dir , "snippets.json" ), "w" , encoding = "utf-8" ) as f :
626626 json .dump (snippets_list , f , indent = 2 , ensure_ascii = False )
627627 f .write ("\n " )
628628 print (f"Rebuilt data/snippets.json for { locale } with { len (snippets_list )} entries" )
@@ -655,7 +655,7 @@ def build_locale(locale, templates, all_snippets):
655655 index_dir = os .path .join (SITE_DIR , locale )
656656 os .makedirs (index_dir , exist_ok = True )
657657 index_path = os .path .join (index_dir , "index.html" )
658- with open (index_path , "w" ) as f :
658+ with open (index_path , "w" , encoding = "utf-8" ) as f :
659659 f .write (index_html )
660660 print (f"Generated index.html for { locale } with { len (all_snippets )} cards" )
661661
@@ -667,7 +667,7 @@ def build_locale(locale, templates, all_snippets):
667667def load_templates ():
668668 """Load all HTML templates."""
669669 def _read (path ):
670- with open (path ) as f :
670+ with open (path , encoding = "utf-8" ) as f :
671671 return f .read ()
672672 return {
673673 "page" : _read ("templates/slug-template.html" ),
0 commit comments