I need to encode a filename to escape special characters.
This includes the dot character which could be misinterpreted as moving up a directory (e.g. ..).
Forward slashes do not need to be changed, the filename foo/bar/baz is ok.
I only need to work with strings containing ascii characters.
The escape character could be anything, e.g. #, and the format of the escapes could be anything.
Does such a library or set of well-tested functions exist? If not, how would I achieve this?