cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Unicode characters not shown correctly

From: Zayl Linel <zayl543_at_yahoo.com>
Date: Fri, 10 Aug 2012 17:06:10 -0700 (PDT)

thank you for having taking time to respond to my question. I have a solution that must work. I can save my unicode text into a file called myfile.txt. Now I want to send that file as attachement with the message. I have tried the code below, so when I receive the email, I can see the attachement link but when I click on it, but the content is the message body itself and not the file I want to send. I am certain I am messing a curl function that send attachement but I have no idea how. curl_easy_setopt(hnd, CURLOPT_READFUNCTION, payload_source); curl_easy_setopt(hnd, CURLOPT_READDATA, &upload_ctx); //... static const char *payload_text[]={ "To: <me@mail.com>\n", "From: <me@mail.com>(Example User)\n", "Content-Type: text/plain\n", "Content-Disposition: attachment; filename=\"myfile.txt\"\n", "Subject: Hello!\n", "\n", "Message sent\n", NULL }; struct upload_status { int lines_read; }; static size_t payload_source(void *ptr, size_t size, size_t nmemb, void *userp){ struct upload_status *upload_ctx = (struct upload_status *)userp; const char *data; if ((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) { return 0; } data = payload_text[upload_ctx->lines_read]; if (data) { size_t len = strlen(data); memcpy(ptr, data, len); upload_ctx->lines_read ++; return len; } return 0; } ________________________________ From: Dan Fandrich <dan@coneharvesters.com> To: curl-users@cool.haxx.se Sent: Friday, August 10, 2012 10:35 PM Subject: Re: Unicode characters not shown correctly On Fri, Aug 10, 2012 at 10:46:43AM -0700, Zayl Linel wrote: > Hi, I am making a c program that supports many languages. The program send > emails using the type WCHAR instead of char. The problem is that when I receive > the email and read it, some characters are not shown correctly even some > english ones like e,m, ... This is an example : > >   curl_easy_setopt(hnd, CURLOPT_READFUNCTION, payload_source); >   curl_easy_setopt(hnd, CURLOPT_READDATA, &upload_ctx); > > static const WCHAR *payload_text[]={ >     L"To: <me@mail.com>\n", >     L"From: <me@mail.com>(Example User)\n", >     L"Subject: Hello!\n", >     L"\n", >     L"Message sent\n", >     NULL > }; RFC5322 doesn't support UNICODE. Read the RFC (and the MIME ones) to find out how to properly format a message. In short: WCHAR isn't going to work. >>> Dan ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-users FAQ:        http://curl.haxx.se/docs/faq.html Etiquette:  http://curl.haxx.se/mail/etiquette.html

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-08-11