What is the proper way to convert an XML URI into a Windows file path?
As a starting point, it's possible to turn:
file:///C:/DirA/DirB/File.txt
into:
C:\DirA\DirB\File.txt
... by first dropping the file:///
substring (having used it to determine we're dealing with a local file) and then placing a backslash wherever a slash appears in the original string. That seems like a good start, but it's not enough. For instance, the URI might look like this:
file:///C:/DirA/DirB/With%20Spaces.txt
... which becomes:
C:\DirA\DirB\With Spaces.txt
... after replacing %20s with spaces. Even that, however, would not be enough, as it may likewise be necessary to deal with other such encodings. Furthermore, some of those characters will not be legal Windows filename charcters, so it's necessary to identify which of those encodings are valid in Windows filenames and flag an error if anything else is encountered.
Is there anything else I'm forgetting? Anybody care to expand on the above?