RFC 3986
std.uri
Encode and decode Uniform Resource Identifiers (URIs). URIs are used in internet transfer protocols. Valid URI characters consist of letters, digits, and the characters ;/?:@&=+$,-_.!~*'() Reserved URI characters are ;/?:@&=+$, Escape sequences consist of % followed by two hex digits.
See Also
Copyright
Copyright The D Language Foundation 2000 - 2009.
License
class URIException
Types 1
classURIException : Exception
This Exception is thrown if something goes wrong when encoding or decoding a URI.
Functions 10
fn
string decode(Char)(scope const(Char)[] encodedURI) if (isSomeChar!Char)Decodes the URI string encodedURI into a UTF-8 string and returns it. Escape sequences that resolve to reserved URI characters are not replaced. Escape sequences that resolve to the '#' character a...fn
string decodeComponent(Char)(scope const(Char)[] encodedURIComponent) if (isSomeChar!Char)Decodes the URI string encodedURI into a UTF-8 string and returns it. All escape sequences are decoded.fn
string encode(Char)(scope const(Char)[] uri) if (isSomeChar!Char)Encodes the UTF-8 string uri into a URI and returns that URI. Any character not a valid URI character is escaped. The '#' character is not escaped.fn
string encodeComponent(Char)(scope const(Char)[] uriComponent) if (isSomeChar!Char)Encodes the UTF-8 string uriComponent into a URI and returns that URI. Any character not a letter, digit, or one of -_.!~*'() is escaped.fn
ptrdiff_t uriLength(Char)(scope const(Char)[] s) if (isSomeChar!Char)Does string s[] start with a URL? Returns: -1 it does not len it does, and s[0 .. len] is the slice of s[] that is that URLfn
ptrdiff_t emailLength(Char)(scope const(Char)[] s) if (isSomeChar!Char)Does string s[] start with an email address? Returns: -1 it does not len it does, and s[0 .. i] is the slice of s[] that is that email address References: RFC2822Variables 2
private var
char[16] hex2ascii = "0123456789ABCDEF"private var
ubyte[128] uri_flags = ({
ubyte[128] uflags;
// Compile time initialize
uflags['#'] |= URI_Hash;
foreach (c; 'A' .. 'Z' + 1)
{
uflags[c] |= URI_Alpha;
uflags[c + 0x20] |= URI_Alpha; // lowercase letters
}
foreach (c; '0' .. '9' + 1) uflags[c] |= URI_Digit;
foreach (c; ";/?:@&=+$,") uflags[c] |= URI_Reserved;
foreach (c; "-_.!~*'()") uflags[c] |= URI_Mark;
return uflags;
})()