Handling Uniform Resource Locators

A Uniform Resource Locator (URL) is a compact representation of the location and access method for a resource located on the Internet. Each URL consists of a scheme (HTTP, HTTPS, or FTP) and a scheme-specific string. This string can include a combination of a directory path, search string, or resource name. The WinInet functions provide the ability to create, combine, parse, and canonicalize URLs.

URLs must follow the accepted syntax and semantics to access resources through the Internet. Canonicalization is the process that converts a URL, that might contain unsafe characters, such as blank spaces, and reserved characters, into an accepted format.

The InternetCanonicalizeUrl function can be used to canonicalize URLs. InternetCanonicalizeUrl does not verify that the URL passed to it is canonicalized or that the URL it returns is valid.

The URL functions operate in a task-oriented manner. The content and format of the URL passed to the function is not verified. The calling application should track the use of these functions to ensure the data is in the intended format. For example, the InternetCanonicalizeUrl function would convert the character % into the escape sequence "%25" when using no flags. If InternetCanonicalizeUrl is used on the canonicalized URL, the escape sequence "%25" would be converted into the escape sequence "%2525", which is invalid.

Characters that must be encoded include any characters that have no corresponding graphic character in the US-ASCII coded character set; hexadecimal 80-FF, which are not used in the US-ASCII coded character set, and hexadecimal 00-1F and 7F, which are control characters; blank spaces, % , which is used to encode other characters, and unsafe characters such as <, >, ", #, {, }, |, \, ^, ~, [, ], and '.

Note A relative URL is a compact representation of the location of a resource relative to an absolute base URL. The base URL must be known to the parser and usually includes the scheme, network location, and parts of the URL path. An application can call the InternetCombineUrl function to combine the relative URL with its base URL. InternetCombineUrl also canonicalizes the resulting URL.