url encode: Difference between revisions

From Onset Developer Wiki
No edit summary
No edit summary
Line 22: Line 22:


{{RelatedFunctions}}
{{RelatedFunctions}}
[[Template:HttpFunctions]]
{{HttpFunctions}}

Revision as of 21:44, 19 January 2020

url encode

Type: Function
Context: Server & Client
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