Is there some standard method to remove all characters from string that cannot be used for a filenames in osx? Does the characters you are allowed to use correspond to some commonly used category? (I know defining a list of allowed characters would be possible, but I want to be able to use filenames from several languages (chinese, among others), so this will be a bit of a pain.) A solution that works in ubuntu too, would be great.
Is there some standard method to remove all characters from string that cannot be
Share
I use the following code to convert a arbitrary string into a valid filename. It follows similar rules (if not the same) to those applied to creating a webloc file when dragging a URL to the Desktop.
At the Darwin level “/” characters are stored as “:” characters (and vice versa). They are removed here for cosmetic reasons.