Hi,
I don't know anything about libcurl, and I haven't tried to build
and execute your program. I've just studied your code a bit.
Are you aware that n in Glib::append(const char* src, size_type n)
is _not_ the number of bytes to append? It's the number of UTF-8
encoded Unicode characters.
If size*nmemb in writefunction() is the number of bytes to append,
and data contains utf-8 encoded data with multi-byte characters,
buffer->append(data, size*nmemb) will try to append too much. You
can try using template<class In> Glib::ustring&
Glib::append(In pbegin, In pend):
buffer->append(data, data + size*nmemb);
If data does not contain utf-8 encoded data, you should not use
Glib::ustring.
Kjell
2011-12-09 19:16, Spazzatura.Live skrev:
Hello!
Sorry, it was a part of a bigger code, in the new attached archive
i added a simple main.cc which can be compiled with: g++
$(pkg-config gtkmm-2.4 libcurl --libs --cflags) main.cc -o main
(if you want i can also add a makefile)
Thanks.
Regars,
Stefano
Il 09/12/2011 19:01, Milosz Derezynski ha scritto:
Hello,
Your testcase is broken, I was not able to compile it (I
didn't edit any files), and details are missing:
- What is your version of gtkmm?
Please provide a code example that does compile; a makefile
would make it perfect.
Regards
Milosz
On Fri, Dec 9, 2011 at 5:24 PM,
Spazzatura.Live <kharhonte hotmail com>
wrote:
Probably
this is more a libcurl question than a gtkmm one, but i
saw an example in which a std::string works so:
When i let curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION,
writefunction), on my ustring:
int writefunction(char *data, size_t size, size_t
nmemb, Glib::ustring *buffer)
{tow
if(buffer!=NULL)
{
buffer->append(data, size*nmemb);
return size*nmemb;
}
return 0;
}
it gives always a segmentation fault.
Attached the code.
_
|