cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: unicode in CURLOPT_POST

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Thu, 19 Apr 2012 19:06:12 +0200

On Thu, Apr 19, 2012 at 06:48:35PM +0200, Kublo Enter wrote:
> my problem is that when I trying to send data to the server witch option
> CURLOPT_POSTFIELDS I fail it.
>
> I'm trying to do it in such a way:
>
> const wchar_t *datapost=L"some=abc";
>
> curl_easy_setopt(curl, CURLOPT_POSTFIELDS,datapost);
> curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, size);
>
> I do not know how I get size "datapost" and if I can in such a way to send
> data?
>
> With const char * I do not have any problems.

libcurl wants the size in bytes, so the code needs to calculate that. In this
case, sizeof(*datapost)-sizeof(wchar_t) should do it, or
wcslen(datapost)*sizeof(wchar_t).

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-04-19