Reputation: 1518
I'm learning C, and I'm using libcURL to send a POST request to log into a website.
I'm stumbling upon a problem, my password contains the ü
character.
Reading the POST request from my browser, I can see it gets encoded as %FC
.
However, when using curl_easy_escape()
to encode it, it encodes as %C3%BC
.
I've gone to search, and found out it's a different encoding. I think ISO, because the page has this meta: <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
However, I can't figure out how to convert it somehow.
Now, how would I go about urlencoding ü
as %FC
?
Upvotes: 0
Views: 111
Reputation: 215261
Use of non-UTF-8 encodings for POST is an utter mess and the behavior actually varied quite a bit between browsers, so it's considered very bad practice to do this. But since you're stuck with a site that does, you'll have to work around it.
I can't find a curl api for doing percent encoding with alternate charsets so you might have to do it yourself (first use iconv
to convert from your system's native encoding, hopefully UTF-8, to ISO-8859-1 (Latin-1), then do the percent encoding manually).
One idea - are you sure you even should be doing your own escaping? My impression is that it's just meant for URLs, and the curl API for POSTing forms may already do escaping internally (not sure), in which case you probably just have to tell it the right content type.
Upvotes: 1