NaviServer - programmable web server

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

# ns_urlencode(n) 4.99.8 naviserver "NaviServer Built-in Commands"

## Name

ns_urlencode - Encode a string to its URL-encoded representation

## Table Of Contents

## Synopsis

- ns_urlencode ?-charset charset? ?-part part? ?--? components

## Description

This command encodes a string according to the rules for URL encoding defined in RFC #1738, Uniform Resource Locators. ns_urlencode codes essentially all non-alphanumeric characters in the specified components. The epcial octets are encoded by a "%" followed by the two-character hexa- decimal representation for the octet.

## COMMANDS

ns_urlencode ?-charset charset? ?-part part? ?--? components

The option charset can be used to specify the character set of the encode operation. Option part is used to specify the query (default) or path encoding. In the query mode, the components will be concatenated via "&", in the path mode the components are concatenated with "/".

## EXAMPLES

      ns_urlencode http://www.aolserver.com/redirect.adp?url=http://www.aol.com&t=1,2,3

The example outputs the following line

       http%3a%2f%2fwww%2eaolserver%2ecom%2fredirect%2eadp%3furl%3dhttp%3a%2f%2fwww%2eaol%2ecom%26t%3d1%2c2%2c3

## See Also

ns_charsets, ns_urlcharset, ns_urldecode, nsd

## Keywords

charset, encoding, url