Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
a local clone.
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.
License:
Authors:
Source std/uri.d
- class
URIException
: object.Exception; - This Exception is thrown if something goes wrong when encoding or decoding a URI.
- string
decode
(Char)(in 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 are not replaced. - string
decodeComponent
(Char)(in Char[]encodedURIComponent
)
if (isSomeChar!Char); - Decodes the URI string encodedURI into a UTF-8 string and returns it. All escape sequences are decoded.
- string
encode
(Char)(in 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. - string
encodeComponent
(Char)(in 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. - ptrdiff_t
uriLength
(Char)(in Char[]s
)
if (isSomeChar!Char); - Does string
s
[] start with a URL?Returns:-1 it does not len it does, ands
[0 .. len] is the slice ofs
[] that is that URLExamples:string s1 = "http://www.digitalmars.com/~fred/fredsRX.html#foo end!"; writeln(uriLength(s1)); // 49 string s2 = "no uri here"; writeln(uriLength(s2)); // -1 assert(uriLength("issue 14924") < 0);
- ptrdiff_t
emailLength
(Char)(in Char[]s
)
if (isSomeChar!Char); - Does string
s
[] start with an email address?Returns:-1 it does not len it does, ands
[0 .. i] is the slice ofs
[] that is that email addressReferences RFC2822
Examples:string s1 = "[email protected] with garbage added"; writeln(emailLength(s1)); // 32 string s2 = "no email address here"; writeln(emailLength(s2)); // -1 assert(emailLength("issue 14924") < 0);
Copyright © 1999-2018 by the D Language Foundation | Page generated by
Ddoc on Tue Mar 13 17:32:22 2018