The library encodes file path separators and common directory names, producing a reversible unicode string that can be used as a filename. It's useful in the case when you want to extract data or features from any file and store them in a specific directory.
It replaces path chars as below:
\/:*?"<>|
be replaced to full width alternative chars of unicode.〇
.```rust use pathtounicode_filename::*;
// make a filename asserteq!(tofilename("/tmp/file.txt"), Ok("/tmp/file.txt".into())); asserteq!(tofilename("C:\Users\alice\file.txt"), Ok("💠🏠alice\file.txt".into())); asserteq!(tofilename("/Users/alice/Documents/file.txt"), Ok("🍎📄alice/file.txt".into()));
// restore the filename to the original path asserteq!(topath("/var/log/file.txt"), Ok("/var/log/file.txt".into())); asserteq!(topath("🐧🥞sdcard001/file.txt"), Ok("/media/sdcard001/file.txt".into())); asserteq!(topath("🍎🎨bob/file.png"), Ok("/Users/bob/Pictures/file.png".into())); ```
License: MIT OR Apache-2.0