Method Protocols.HTTP.uri_encode_invalids()


Method uri_encode_invalids

string uri_encode_invalids(string s)

Description

Encodes all "dangerous" chars in the given string using %XX encoding, so that it can be included as a URI in an HTTP message or header field. This includes control chars, space and various delimiter chars except those in the URI reserved set (RFC 2396 section 2.2).

Since this function doesn't touch the URI reserved chars nor the escape char %, it can be used on a complete formatted URI or IRI.

8-bit chars and wider are encoded using UTF-8 followed by percent-encoding. This follows RFC 3986 section 2.5, the IRI standard (RFC 3987) and appendix B.2 in the HTML 4.01 standard.

Note

The characters in the URI reserved set are: :, /, ?, #, [, ], @, !, $, &, ', (, ), *, +, ,, ;, =. In addition, this function doesn't touch the escape char %.

See also

uri_decode, uri_encode