Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support CSV files with BOM signatures #705

Merged
merged 1 commit into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chirp/drivers/generic_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 5 additions & 2 deletions tests/unit/test_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down