Browse Source

🔨 Fix configuration.py with encoding UTF-8 (#24719)

- Opening files with Windows-1252 encoding.
ButchMonkey 1 year ago
parent
commit
328f6d9aff
No account linked to committer's email address
1 changed files with 5 additions and 5 deletions
  1. 5
    5
      buildroot/share/PlatformIO/scripts/configuration.py

+ 5
- 5
buildroot/share/PlatformIO/scripts/configuration.py View File

@@ -10,7 +10,7 @@ def blab(str,level=1):
10 10
     if verbose >= level: print(f"[config] {str}")
11 11
 
12 12
 def config_path(cpath):
13
-    return Path("Marlin", cpath)
13
+    return Path("Marlin", cpath, encoding='utf-8')
14 14
 
15 15
 # Apply a single name = on/off ; name = value ; etc.
16 16
 # TODO: Limit to the given (optional) configuration
@@ -23,7 +23,7 @@ def apply_opt(name, val, conf=None):
23 23
     # Find and enable and/or update all matches
24 24
     for file in ("Configuration.h", "Configuration_adv.h"):
25 25
         fullpath = config_path(file)
26
-        lines = fullpath.read_text().split('\n')
26
+        lines = fullpath.read_text(encoding='utf-8').split('\n')
27 27
         found = False
28 28
         for i in range(len(lines)):
29 29
             line = lines[i]
@@ -46,7 +46,7 @@ def apply_opt(name, val, conf=None):
46 46
 
47 47
         # If the option was found, write the modified lines
48 48
         if found:
49
-            fullpath.write_text('\n'.join(lines))
49
+            fullpath.write_text('\n'.join(lines), encoding='utf-8')
50 50
             break
51 51
 
52 52
     # If the option didn't appear in either config file, add it
@@ -67,7 +67,7 @@ def apply_opt(name, val, conf=None):
67 67
 
68 68
         # Prepend the new option after the first set of #define lines
69 69
         fullpath = config_path("Configuration.h")
70
-        with fullpath.open() as f:
70
+        with fullpath.open(encoding='utf-8') as f:
71 71
             lines = f.readlines()
72 72
             linenum = 0
73 73
             gotdef = False
@@ -79,7 +79,7 @@ def apply_opt(name, val, conf=None):
79 79
                     break
80 80
                 linenum += 1
81 81
             lines.insert(linenum, f"{prefix}#define {added} // Added by config.ini\n")
82
-            fullpath.write_text('\n'.join(lines))
82
+            fullpath.write_text('\n'.join(lines), encoding='utf-8')
83 83
 
84 84
 # Fetch configuration files from GitHub given the path.
85 85
 # Return True if any files were fetched.

Loading…
Cancel
Save