filename_to_url
filename_to_url (path)
This function returns the file name path converted to a UTF8–encoded file-scheme URL conforming to RFC 1738. It converts the file name to an absolute path name, replaces all file separator characters with '/', and encodes all non-alphanumeric characters (except for $, -, _, ., +, !, *, ', (, ), /, and :) into a sequence of one or more 3-character strings %XX, where the XX values are the two digit hexadecimal codes for the UTF-8 encoding of the character. It returns the result prefixed with file://. If the file name is a directory, a trailing / is appended to the result.
|
The file name should not include a fragment or anchor identifier (for example, Xpointer) specification; but this can be appended to the result.
|
For example, the following function:
filename_to_url('article#1.xml')
would return a string like the following:
file:///C:/documents/article%231.xml
As another example, the function:
filename_to_url('c:\file' . chr(0x3042) . '.txt')
would produce:
file:///C:/file%E3%81%82.txt
Related Topics