URL Encoding
|
 |
|
|
|
| void UrlEncode (Str& dest, BOOL spaceAsPlus =
FALSE) |
Not compatible with STR_NO_RTLIBRARY
|
Encodes the URL contained in the string object appropriately according to the
URI RFCs. The spaceAsPlus flag indicates how to treat the most common URL
encoding exception - the space character. Specifically:
-
Blanks are replaced by the + sign (when spaceAsPlus=TRUE) or by %20 (when
spaceAsPlus=FALSE)
-
"Unsafe" characters - a lot of the non-alphanumerics fall into this category -
are converted to %nn representation
-
"International" characters (with codes >=127, including all Unicode
characters encodable in UTF-8 with more than one byte) are escaped
The result is stored in the passed string object.
Important:
-
When Str Library is compiled in Unicode mode, the method will internally obtain
a UTF-8 representation of any extended characters found in the source string,
because the RFCs require UTF-8 encoding in those cases
-
When Str Library is compiled in ANSI mode, the caller is responsible for having
any extended characters encoded in UTF-8. If the source string contains
non-UTF8 extended characters, the resulting representation will not be in
accordance with the standard
At the time of this writing, the most current RFC describing the URI / URL
encoding process is the
RFC 3986
See also: Basic operations