cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: HTTP post problem with quoted string as param

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Fri, 2 Dec 2011 11:48:43 -0800

On Fri, Dec 02, 2011 at 04:08:54PM +0530, Vinoth raj wrote:
> The point "treat %e2%80%9cQuote%203%e2%80%9d" as ISO-8859-1 is not clear to me.
> On converting "Quote 3" to UTF-8 in my C++ app I get the encoded string as
> %e2%80%9cQuote%203%e2%80%9d
> So, %e2%80%9cQuote%203%e2%80%9d is basically UTF-8.

That's the problem--don't do the conversion your C++ app. It looks like the server
already does the conversion. When that happens, it's converted twice and you
get garbage.

> Now I am posting this UTF-8 encoded string to server through HTTP post.
> On the server (Apache Tomcat) side I had tried setting the content-type to
> ISO-8859-1 but received junkQuotejunk.
> UTF-8 as content-type also yielded same.

Then, perhaps there's no way to stop the server from doing the conversion itself.

> So, when sending the UTF-8 encoded string should I set any encoding type in C++
> using curl.

But, you said above that that doesn't work.

> Also, what encoding type should I set on server side?
>
> I tried this:
>
> C++ side
> Curl post parameter: mystring=%e2%80%9cQuote%203%e2%80%9d
>
> Servlet side
> request.setContentType("text/html", charset=ISO-8859-1);
> Now, request.getParameter("mystring") yielded
> %C3%A2%C2%80%C2%9CQuote%203%C3%A2%C2%80%C2%9D
> Tried, URIDecoder.decode(request.getParameter("mystring"), "ISO-8859-1")
> yielded junkQuotejunk

I don't know what this code is.

> In short, what encoding type should I set at C++ side using CURL and also at
> server side?

That's entirely between you and the server. Once you figure that out, then you
can have curl send it as appropriate.

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-12-02