Open all files with utf-8 encoding

- will not be used for binary read/writes (rb,wb)!
- prevents a bug where units with special characters in the unit name can not be tracked anymore as there will be a name mismatch due to wrong encoding
This commit is contained in:
RndName
2021-08-12 23:32:09 +02:00
parent c80d0e5378
commit b5b0d82a1a
9 changed files with 10 additions and 8 deletions

View File

@@ -325,7 +325,7 @@ class AircraftType(UnitType[Type[FlyingType]]):
logging.warning(f"No data for {aircraft.id}; it will not be available")
return
with data_path.open() as data_file:
with data_path.open(encoding="utf-8") as data_file:
data = yaml.safe_load(data_file)
try:

View File

@@ -67,7 +67,7 @@ class GroundUnitType(UnitType[Type[VehicleType]]):
logging.warning(f"No data for {vehicle.id}; it will not be available")
return
with data_path.open() as data_file:
with data_path.open(encoding="utf-8") as data_file:
data = yaml.safe_load(data_file)
try:

View File

@@ -386,7 +386,7 @@ class PollDebriefingFileThread(threading.Thread):
os.path.isfile("state.json")
and os.path.getmtime("state.json") > last_modified
):
with open("state.json", "r") as json_file:
with open("state.json", "r", encoding="utf-8") as json_file:
json_data = json.load(json_file)
debriefing = Debriefing(json_data, self.game, self.unit_map)
self.callback(debriefing)

View File

@@ -65,7 +65,7 @@ class Operation:
@classmethod
def prepare(cls, game: Game) -> None:
with open("resources/default_options.lua", "r") as f:
with open("resources/default_options.lua", "r", encoding="utf-8") as f:
options_dict = loads(f.read())["options"]
cls._set_mission(Mission(game.theater.terrain))
cls.game = game

View File

@@ -12,7 +12,7 @@ def _build_version_string() -> str:
]
build_number_path = Path("resources/buildnumber")
if build_number_path.exists():
with build_number_path.open("r") as build_number_file:
with build_number_path.open("r", encoding="utf-8") as build_number_file:
components.append(build_number_file.readline())
if not Path("resources/final").exists():