_ENCODEURL$

From QB64 Phoenix Edition Wiki
Revision as of 18:33, 25 November 2024 by RhoSigma (talk | contribs) (Created page with "{{DISPLAYTITLE:_ENCODEURL$}} The '''_ENCODEURL$''' function returns the so called percent encoded representation of the given URL. {{PageSyntax}} : result$ = _ENCODEURL$({{Parameter|url$}}) {{PageParameters}} * {{Parameter|url$}} is the URL to encode as variable or literal STRING. {{PageDescription}} * URL encoding may be required before trying to retrieve it using the _OPENCLIENT("HTTP:url") command. * Proper encoding is under the obligatio...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The _ENCODEURL$ function returns the so called percent encoded representation of the given URL.


Syntax

result$ = _ENCODEURL$(url$)


Parameters

  • url$ is the URL to encode as variable or literal STRING.


Description

  • URL encoding may be required before trying to retrieve it using the _OPENCLIENT("HTTP:url") command.
  • Proper encoding is under the obligation of the application, because only that knows how the URL currently looks like and hence if encoding is required or not.
  • This function performs the most simple encoding according to the informations found here, which is sufficient for the most work cases.
    • Chars - . _ ~ 0 to 9 Aa to Zz (not encoded).
    • Chars # / : ? @ [ ] (not encoded in address part but encoded in query part, first ? is not encoded and starts the query part).
    • Chars & = (not encoded as query key separator respectively query value assignment on a simple 1:1 swap base).
    • Control chars, spaces and extended ASCII (>127) are always encoded, regardless in which part of the URL they are used.
    • If the application uses unconventional URL notation, e.g. query parts like ?foo=bar&baz&flip=true where the use of ampersands (&) is ambigous, then it must implement its own custom encoding routine, as only the application knows the correct syntax in such cases.
  • Note that this function performs no validation of the given URL, it expects a valid URL to be given and just does the encoding.
  • Note also that it does not check, if the URL is already encoded. Although multiple times encoded URLs should not be a problem for most servers, it's recommended to avoid it.


Availability


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link