diff --git a/lib/libesp32/berry/tools/coc/block_builder.py b/lib/libesp32/berry/tools/coc/block_builder.py index 2d76465df455..6535fd40be46 100644 --- a/lib/libesp32/berry/tools/coc/block_builder.py +++ b/lib/libesp32/berry/tools/coc/block_builder.py @@ -159,7 +159,7 @@ def name(self, block): def writefile(self, filename, text): otext = "#include \"be_constobj.h\"\n\n" + text - with open(filename, "w") as f: + with open(filename, "w", encoding='utf-8') as f: f.write(otext) def dumpfile(self, path): diff --git a/lib/libesp32/berry/tools/coc/coc b/lib/libesp32/berry/tools/coc/coc index 2111b1ea27d0..1a12c01e6afc 100755 --- a/lib/libesp32/berry/tools/coc/coc +++ b/lib/libesp32/berry/tools/coc/coc @@ -34,7 +34,7 @@ class builder: if re.search(r"\.(h|c|cc|cpp)$", filename): # print(f"> parse {filename}") text = "" - with open(filename) as f: + with open(filename, encoding='utf-8') as f: text = f.read() # print(f"> len(text)={len(text)}") parser = coc_parser(text) diff --git a/lib/libesp32/berry/tools/coc/macro_table.py b/lib/libesp32/berry/tools/coc/macro_table.py index 8b4518ddc955..de741040e11f 100644 --- a/lib/libesp32/berry/tools/coc/macro_table.py +++ b/lib/libesp32/berry/tools/coc/macro_table.py @@ -22,7 +22,7 @@ def parse_value(self, s): def scan_file(self, filename): str = "" - with open(filename) as f: + with open(filename, encoding='utf-8') as f: str = f.read() r = macro_table.pat.findall(str) for it in r: diff --git a/lib/libesp32_lvgl/lv_binding_berry/tools/preprocessor.py b/lib/libesp32_lvgl/lv_binding_berry/tools/preprocessor.py index f71335eb9f23..c829c484b1b9 100644 --- a/lib/libesp32_lvgl/lv_binding_berry/tools/preprocessor.py +++ b/lib/libesp32_lvgl/lv_binding_berry/tools/preprocessor.py @@ -86,7 +86,7 @@ def clean_source(raw): # headers_names = [ '../../lib/libesp32_lvgl/LVGL/src/lv_api_map.h' ] output_filename = "../mapping/lv_funcs.h" -sys.stdout = open(output_filename, 'w') +sys.stdout = open(output_filename, 'w', encoding='utf-8') print(""" // Automatically generated from LVGL source with `python3 preprocessor.py` @@ -121,7 +121,7 @@ def clean_source(raw): """) for header_name in headers_names: - with open(header_name) as f: + with open(header_name, encoding='utf-8') as f: print("// " + header_name) raw = clean_source(f.read()) @@ -198,7 +198,7 @@ def clean_source(raw): headers_names = list_files(lv_src_prefix, lv_fun_globs) output_filename = "../mapping/lv_enum.h" -sys.stdout = open(output_filename, 'w') +sys.stdout = open(output_filename, 'w', encoding='utf-8') print("""// ====================================================================== // Functions // ====================================================================== diff --git a/pio-tools/metrics-firmware.py b/pio-tools/metrics-firmware.py index 623256245954..2d7cae427ba8 100644 --- a/pio-tools/metrics-firmware.py +++ b/pio-tools/metrics-firmware.py @@ -10,7 +10,7 @@ def firm_metrics(source, target, env): env.Execute("$PYTHONEXE -m tasmota_metrics \"" + str(tasmotapiolib.get_source_map_path(env).resolve()) + "\"") elif env["PIOPLATFORM"] == "espressif8266": map_file = join(env.subst("$BUILD_DIR")) + os.sep + "firmware.map" - with open(map_file,'r') as f: + with open(map_file,'r', encoding='utf-8') as f: phrase = "_text_end = ABSOLUTE (.)" for line in f: if phrase in line: