NaviServer - programmable web server
4.99  5.0

[ Main Table Of Contents | Table Of Contents | Keyword Index ]

ns_parsequery(n) 5.0.0a naviserver "NaviServer Built-in Commands"

Name

ns_parsequery - Parse a URL query string into an ns_set

Table Of Contents

Synopsis

Description

Parse HTTP query parameters.

COMMANDS

ns_parsequery ?-charset charset? ?-fallbackcharset fallbackcharset? ?--? querystring

This command parses the specified HTTP querystring into an ns_set, which is returned. The keys and values will be decoded based by the rules used for ns_urlencode. In case the query cannot be parsed to the charset, an exception is raised (with exception code NS_INVALID_UTF8).

The option -charset can be used to specify the character set of the encode operation.

The option -fallbackcharset can be used to specify an alternative character set when the conversion of the querystring leads to invalid UTF-8. Instead of raising an exception, a second attempt of decoding the query string is made with the fallback charset. Note that the fallback charset can be provided as well via the configuration parameter formfallbackcharset. For more details, see ns_getform.

EXAMPLES

 % set s [ns_parsequery "msg=Hello+World%21&a=b&a=b&c=d"]
 d0
 
 % ns_set array $s
 msg {Hello World!} a b a b c d

See Also

ns_getform, ns_parseurl, ns_set, ns_urlencode

Keywords

URL, charset, encoding, formfallbackcharset, global built-in, query, urlcharset