See What to use for URL encoding? - #3 by quinnj — the HTTP.jl package the URIs.jl package has a function escapeuri
to escape strings for URIs. It won’t convert backslash to forward slashes, but you can apply it to each component of the path (via splitpath
, which splits by \
on Windows) to escape special characters like spaces. In particular, you can define the function:
import URIs
path2uri(path) = "file://" * join(map(URIs.escapeuri, splitpath(path)), '/')
and apply it to convert your path to a file://
URI.
(It might be nice to have a function like this in the URIs.jl package if someone feels like filing an issue or making a PR for the issue: filepath2uri function? · Issue #61 · JuliaWeb/URIs.jl · GitHub)