url encode: Difference between revisions

From Onset Developer Wiki
Created page with "{{Info|Function|Server & Client|1.0.3}} {{FuncDescription|Encodes your string so it is safe to send with an URL.}} {{FuncSyntax|url_encode(str)}} {{FuncParameters}} {{FuncP..."
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
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.}}
Line 22: Line 22:


{{RelatedFunctions}}
{{RelatedFunctions}}
{{HttpFunctions}}

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