I want to create a sane/safe filename (i.e. somewhat readable, no \"strange\" characters, etc.) from some random Unicode string (mich might contain just anything).
(
No solutions here, only problems that you must consider:
what is your minimum maximum filename length? (e.g. DOS supporting only 8-11 characters; most OS don't support >256 characters)
what filenames are forbidden in some context? (Windows still doesn't support saving a file as CON.TXT -- see https://blogs.msdn.microsoft.com/oldnewthing/20031022-00/?p=42073)
remember that . and .. have specific meanings (current/parent directory) and are therefore unsafe.
is there a risk that filenames will collide -- either due to removal of characters or the same filename being used multiple times?
Consider just hashing the data and using the hexdump of that as a filename?