diff --git a/chirp/drivers/generic_csv.py b/chirp/drivers/generic_csv.py index 1d5cf4fe4..92eb071b1 100644 --- a/chirp/drivers/generic_csv.py +++ b/chirp/drivers/generic_csv.py @@ -195,7 +195,7 @@ def load(self, filename=None): self._blank() - with open(self._filename, newline='', encoding='utf-8') as f: + with open(self._filename, newline='', encoding='utf-8-sig') as f: return self._load(f) def _load(self, f): diff --git a/tests/unit/test_csv.py b/tests/unit/test_csv.py index c854e578a..68bbcb957 100644 --- a/tests/unit/test_csv.py +++ b/tests/unit/test_csv.py @@ -52,8 +52,8 @@ def test_parse_legacy(self): self.assertEqual('NFM', mem.mode) self.assertEqual(12.5, mem.tuning_step) - def test_parse_modern(self): - with open(self.testfn, 'w', encoding='utf-8') as f: + def test_parse_modern(self, output_encoding='utf-8'): + with open(self.testfn, 'w', encoding=output_encoding) as f: f.write(CHIRP_CSV_MODERN) csv = generic_csv.CSVRadio(self.testfn) mem = csv.get_memory(1) @@ -72,6 +72,9 @@ def test_parse_modern(self): self.assertEqual('5.0W', str(mem.power)) self.assertIn('UHF calling', mem.comment) + def test_parse_modern_bom(self): + self.test_parse_modern(output_encoding='utf-8-sig') + def test_parse_minimal(self): with open(self.testfn, 'w', encoding='utf-8') as f: f.write(CHIRP_CSV_MINIMAL)