curl-library
Re: Problem with CURLOPT_WRITEDATA getting Binary data
Date: Sun, 30 May 2010 17:44:16 +0200
On Sun, May 30, 2010 at 17:36, Kalidoss Sivasamy <kalidoss2_at_gmail.com> wrote:
> Ok, I modified the code, first not null terminate ( //mem->memory[mem->size]
> = 0;). Also, changed the print routine to print each char at a time.
>
> void printText(char* s){
> int len = strlen(s);
> for (int i = 0; i < len; i++) {
> printf("%c", *s++);
> }
> }
It's the same trap you're falling into, you _can't_ handle binary data
as strings.
The strlen() will return the number of bytes up to, but not including,
the first \0 (binary zero) in the data stream. You just can't do it
that way. Use fwrite, as Kamil suggested. Or at least anything not
using str* functions, or printf.
If you have the size available then you could do e.g.
for (i = 0; i < chunk.size; i++) {
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-05-30