PowerBuilder
PowerBuilder
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.Note: This example uses the new DecodeAndAppend method added in Chilkat v9.5.0.87.
Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
string ls_NameWindows1252UrlEncoded
oleobject loo_Sb1
oleobject loo_Http
oleobject loo_SbUrl
string ls_ResponseBody
li_Success = 0
// We have the string "MÆRSK".
// This is the URL encoding of the windows-1252 representation.
ls_NameWindows1252UrlEncoded = "M%C6RSK"
loo_Sb1 = create oleobject
li_rc = loo_Sb1.ConnectToNewObject("Chilkat.StringBuilder")
if li_rc < 0 then
destroy loo_Sb1
MessageBox("Error","Connecting to COM object failed")
return
end if
li_Success = loo_Sb1.DecodeAndAppend(ls_NameWindows1252UrlEncoded,"url","windows-1252")
loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
// 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
loo_SbUrl = create oleobject
li_rc = loo_SbUrl.ConnectToNewObject("Chilkat.StringBuilder")
loo_SbUrl.Append("https://www.chilkatsoft.com/something?name=")
loo_SbUrl.Append(loo_Sb1.GetEncoded("url","utf-8"))
Write-Debug loo_SbUrl.GetAsString()
ls_ResponseBody = loo_Http.QuickGetStr(loo_SbUrl.GetAsString())
// 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
loo_SbUrl.Clear()
loo_SbUrl.Append("https://www.chilkatsoft.com/something?name=")
loo_SbUrl.Append(loo_Sb1.GetEncoded("url","windows-1252"))
Write-Debug loo_SbUrl.GetAsString()
ls_ResponseBody = loo_Http.QuickGetStr(loo_SbUrl.GetAsString())
destroy loo_Sb1
destroy loo_Http
destroy loo_SbUrl