I would like to save a file with the name that has the most valid characters remaining intact, f.e. if I get supplied the filename:
>This\ Ăwesomé_Song?©.mp3
and I want to save it under Windows 7
, it won't let me save it until I remove >
, \
and ?
. The characters Ă
, ©
and é
are totally fine and I would like to keep them intact (instead of f.e. just running everything through an ASCII
filter).
I don't know which characters are allowed f.e. under Unix
and the like but I would like it to work platform-independently. The way I would solve this problem is by implementing a list of strings that each contain a class of characters, ranked from most vicious (f.e. ?
) to most harmless (f.e. the letter a
) and knocking them out string by string until I get a filename that i can save.
Language is Python
, thanks!