Function encode_path

Source
pub fn encode_path<P>(p: &P) -> Cow<'_, str>
where P: AsRef<Path>,
Expand description

Converts the Path P to a UTF-8 string which can be safely written to a file irrespective of whether the original Path contains unprintable characters or is an invalid UTF-8 string. If the Path is a valid UTF-8 string and contains no control characters such as \t it is returned as-is, otherwise it is encoded as a Base-64 string and given a special prefix which means the resultant string can be unambiguously detected as an encoded path rather than an actual path. This conversion can be reversed using the decode_path function.