Rust
Rust
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 Rust Downloads
// We have the string "MÆRSK".
// This is the URL encoding of the windows-1252 representation.
let name_windows1252_url_encoded = "M%C6RSK".to_string();
let sb1 = chilkat::StringBuilder::new();
let _ = sb1.decode_and_append(&name_windows1252_url_encoded, "url", "windows-1252").is_ok();
let 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
let sb_url = chilkat::StringBuilder::new();
let _ = sb_url.append("https://www.chilkatsoft.com/something?name=");
let _ = sb_url.append(&sb1.get_encoded("url", "utf-8").unwrap_or_default());
println!("{}", sb_url.get_as_string().unwrap_or_default());
let mut response_body = http.quick_get_str(&sb_url.get_as_string().unwrap_or_default()).unwrap_or_default();
// 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
sb_url.clear();
let _ = sb_url.append("https://www.chilkatsoft.com/something?name=");
let _ = sb_url.append(&sb1.get_encoded("url", "windows-1252").unwrap_or_default());
println!("{}", sb_url.get_as_string().unwrap_or_default());
response_body = http.quick_get_str(&sb_url.get_as_string().unwrap_or_default()).unwrap_or_default();