url encode: Difference between revisions

From Onset Developer Wiki
No edit summary
No edit summary
 
Line 1: Line 1:
{{Info|Function|Server & Client|1.0.3}}
{{Info|Function|Server|1.0.3}}


{{FuncDescription|Encodes your string so it is safe to send with an URL.}}
{{FuncDescription|Encodes your string so it is safe to send with an URL.}}

Latest revision as of 21:44, 19 January 2020

url encode

Type: Function
Context: Server
Introduced: v1.0.3

Description

Encodes your string so it is safe to send with an URL.

Syntax

url_encode(str)

Parameters

  • str
    The string to encode.

Return Value

  • Returns the encoded string.

Example

local body = ""
body = body.."foo1="..url_encode("bar?")
body = body.."foo2="..url_encode("?d,_:%bar2?")

http_set_body(r, body)
http_set_field(r, "content-length", string.len(body))
http_set_field(r, "content-type", "application/x-www-form-urlencoded; charset=utf-8")

See also