cURL / Mailing Lists / curl-library / Single Mail

curl-library

UNICODE with libcurl on Win2K?

From: Gerard Cheng <cheng_at_vertigoxmedia.com>
Date: Fri, 16 May 2003 12:57:32 -0400

Hi,

I was wondering how to deal with UNICODE when using libcurl
on Win2K. Perhaps an example will best describe the kinds
of problems I am expecting.

Here is a code fragment to call CWD over ftp to check if the
remote directory exists:

        CURL *m_curlHandle;
        CURLcode m_curlReturn;
        struct curl_slist *CWDHeaderList = NULL;
        basic_string<TCHAR> sCWDCmd, sFTPDir;

        ...

                // Test if the directory exists by trying to CWD to it
        sCWDCmd = _T("CWD ") + sFTPDir;
        CWDHeaderList = curl_slist_append(CWDHeaderList, sCWDCmd.c_str());

        (void)curl_easy_setopt(m_curlHandle, CURLOPT_QUOTE, CWDHeaderList);
        m_curlReturn = curl_easy_perform(m_curlHandle);

Under Win2K, when I compile with the pre-processor definitions
"UNICODE" and "_UNICODE", TCHAR's become a wchar_t and the _T()
macro is defined as "L".

My problem is: to call curl_slist_append() above, the second
parameter will need to be converted to a const char*. As written,
there would be a compile error. However, if sFTPDir is a path that
include non-ASCII characters (eg, the path is in Japanese), I can't
use a const char*. How do I handle this?

Thanks in advance,

Gerard

-------------------------------------------------------
Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara
The only event dedicated to issues related to Linux enterprise solutions
www.enterpriselinuxforum.com
Received on 2003-05-16