PowerBuilder
PowerBuilder
URL-Encode a MIME Body
See more MIME Examples
Demonstrates the Chilkat Mime.UrlEncodeBody method, which replaces the current body with an application/x-www-form-urlencoded-style representation using the named charset. The only argument is the charset; it is a void method.
Background: This transforms the body into the form-encoding used by HTML form submissions — spaces to
+, reserved characters to percent-escapes — interpreting the text through the given charset first so non-ASCII characters encode correctly. It is a niche operation for constructing form-style payloads within a MIME part.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Mime
string ls_EncodedBody
li_Success = 0
// Demonstrates the Mime.UrlEncodeBody method, which replaces the current body with an
// application/x-www-form-urlencoded representation using the named charset. The only argument is
// the charset. It is a void method.
loo_Mime = create oleobject
li_rc = loo_Mime.ConnectToNewObject("Chilkat.Mime")
if li_rc < 0 then
destroy loo_Mime
MessageBox("Error","Connecting to COM object failed")
return
end if
li_Success = loo_Mime.SetBodyFromPlainText("name=John Doe & city=New York")
if li_Success = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
return
end if
// URL-encode the body: spaces become "+", reserved characters become %-escapes.
loo_Mime.UrlEncodeBody("utf-8")
ls_EncodedBody = loo_Mime.GetBodyDecoded()
if loo_Mime.LastMethodSuccess = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
return
end if
Write-Debug ls_EncodedBody
destroy loo_Mime