curl-library
Re: getinmemory.c sample crashes with TCHAR
Date: Mon, 13 Nov 2006 13:23:17 -0500
On 11/13/06, Itamar Syn-Hershko <itamar_at_divrei-tora.com> wrote:
> If I'm not wrong, casting the char* to wchar_t* won't just make it
> multi-byte by itself. I tried that now and the non-standard characters I use
> are still not visible. I used those lines of code for casting (I had no idea
> what else to use):
>
> wchar_t* pTemp = new wchar_t[chunk.size];
> pTemp = (wchar_t*)chunk.memory;
> szData.Format(_T("%S"), pTemp);
I'm curious as to why you think the data would necessarily be given to
you in a one-to-one correspondence to the wchar_t byte representation.
Is it not entirely possible that you'll get anything from ASCII,
latin1, UTF-8, UTF-16, UTF-32, and so on depending on what the server
happens to give you. Unless you are guaranteed to be given a
particular encoding of course. Anyway, there's stuff like ICU and
iconv to help with the translation, and the MBCS and related functions
to convert between wide-char and multi-byte sequences. None of which
is particularly related to libcurl as it is simply handing you the raw
bytes. After that you're on your own.
Lars Nilsson
Received on 2006-11-13