curl-library
Re: was: Re: [curlpp-library] A url that supports foreign language and working with charset=UTF-8
Date: Tue, 28 Sep 2004 20:40:13 +0200 (CEST)
On Tue, 28 Sep 2004, Jean-Philippe Barrette-LaPierre wrote:
>> I would like to support a URL that embeds foreign language characters,
>> such as Japanese.
>>
>> To do so, I am trying to communicate to the apache server in UTF-8.
A URL is a URL, it doesn't matter to libcurl what you embed in it. You can
pass on whatever you please (except zero bytes but that isn't valid anyway
according to RFC2616).
>> 1. I have set the charset=UTF-8 as follows:
>> LPCSTR CURLFile::c_szContentType = "Content-Type: text/html;
>> charset=UTF-8";
I hope this is an equivalent of "char *".
The "Content-Type" is only interesting to the server if you POST, not if you
just GET.
>> 2. I convert the URL-path (string contents) to UTF-8 representation and
>> pass it on the server as follows:
>>
>> curl_easy_setopt(m_curl, CURLOPT_URL, m_utfFileName.getNewBuf());
Again, I hope this is is a "char *" you pass on.
Also, for both these strings, you must make sure they are kept while you're
using libcurl since it doesn't duplicate the strings
>> The server returns error 403 ("Forbidden").
So point the URL to your own server and check what path it gets. It gets
exactly what you pass on to libcurl, there is no magic happening.
>> Did anyone succeed in passing a URL that embeds Japanese characters?
You don't exactly "embeds Japanese characters". You just create %-codes in the
proper combination and libcurl supports that.
>> Did anyone succeed with a UFT-8 settings? What is wrong with the above
>> setting?
Again, UTF8 in a URL is _also_ a set of %-codes in the proper combination.
-- Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se Dedicated custom curl help for hire: http://haxx.se/curl.htmlReceived on 2004-09-28