Skip to content

Commit

Permalink
Try code page 437 if ascii fails. Not sure if this is the code page t…
Browse files Browse the repository at this point in the history
…he media player expects (could try 850), nor if the code page is encoded somewhere in the file.
  • Loading branch information
chrrrisw committed Dec 23, 2015
1 parent 9aba2bb commit e3c2713
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions kmeldb/MainIndexEntry.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ def encodedShortdir(self):
Get the 8.3 directory name for the media file and encode it
for writing.
'''
return self._mediaFile.shortdir.encode("ascii")
try:
return self._mediaFile.shortdir.encode("ascii")
except Exception:
print('Error encoding short directory name {} as ascii - will try cp437'.format(
self._mediaFile.shortdir))
print ('Consider renaming {}'.format(self._mediaFile.longdir))
return self._mediaFile.shortdir.encode("cp437")

@property
def shortdir(self):
Expand All @@ -79,7 +85,13 @@ def shortdir(self):
def encodedShortfile(self):
''''''
# The 8.3 filename for the media file
return self._mediaFile.shortfile.encode("ascii")
try:
return self._mediaFile.shortfile.encode("ascii")
except Exception:
print('Error encoding short file name {} as ascii - will try cp437'.format(
self._mediaFile.shortfile))
print ('Consider renaming {}'.format(self._mediaFile.longfile))
return self._mediaFile.shortfile.encode("cp437")

@property
def shortfile(self):
Expand Down

1 comment on commit e3c2713

@chrrrisw
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #9.

Please sign in to comment.