Sample code for 30+ languages & platforms
Lua Requires Chilkat v9.5.0.87+

HTTP GET with utf-8 URL Encoded Query Params

See more HTTP Examples

Demonstrates how to build URLs where query param values can be either URL encoded from the utf-8 representation, or from another charset such as windows-1252.

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

-- We have the string "MÆRSK".

-- This is the URL encoding of the windows-1252 representation.
local nameWindows1252UrlEncoded = "M%C6RSK"

local sb1 = chilkat.StringBuilder.new()
local success = sb1:decode_and_append(nameWindows1252UrlEncoded, "url", "windows-1252")

local http = chilkat.Http.new()

-- Here's how to send an HTTP GET where the param is the utf-8 representation that is URL encoded.
-- For example:  https://www.chilkatsoft.com/something?name=M%C3%A6RSK

local sbUrl = chilkat.StringBuilder.new()

sbUrl:append("https://www.chilkatsoft.com/something?name=")
sbUrl:append(sb1:get_encoded("url", "utf-8"))
print(sbUrl:get_as_string())

local responseBody = http:quick_get_str(sbUrl:get_as_string())

-- Here's how to send an HTTP GET where the param is the windows-1252 representation that is URL encoded.
-- For example:  https://www.chilkatsoft.com/something?name=M%E6RSK

sbUrl:clear()
sbUrl:append("https://www.chilkatsoft.com/something?name=")
sbUrl:append(sb1:get_encoded("url", "windows-1252"))
print(sbUrl:get_as_string())

responseBody = http:quick_get_str(sbUrl:get_as_string())