curl / Mailing Lists / curl-library / Single Mail

curl-library

Libcurl - How to search for Mails with special chars (ä,ö,ü)

From: Unbekannt Unbekannt <xxchillerzz_at_googlemail.com>
Date: Tue, 15 May 2018 10:28:34 +0200

Hey guys,

i use libcurl to search for mails in my mailbox. But i cannot search mails
with mails that inlcudes special chars (ä,ö,ü) in the subject.

Code:

int main(void)
{
  CURL *curl;
  CURLcode res = CURLE_OK;

  curl = curl_easy_init();
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_USERNAME, "myuser");
    curl_easy_setopt(curl, CURLOPT_PASSWORD, "mypassword");

    curl_easy_setopt(curl, CURLOPT_URL, "imaps://imap.gmail.com:993/INBOX");

    curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "SEARCH SUBJECT
Spülmaschine");

    res = curl_easy_perform(curl);

    if(res != CURLE_OK)
      fprintf(stderr, "curl_easy_perform() failed: %s\n",
              curl_easy_strerror(res));

    curl_easy_cleanup(curl);
  }

  return (int)res;
}

curl_easy_perform() returns CURLE_QUOTE_ERROR.

Some other trys that not work:

curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "SEARCH CHARSET UTF-8 SUBJECT
\x53\x70\xc3\xbc\x6c\x6d\x61\x73\x63\x68\x69\x6e\x65"); //CURLE_QUOTE_ERROR

UTF7:
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "SEARCH SUBJECT
Sp+APw-lmaschine"); //CURLE_OK but no result

sprintf(strSearchString, "SEARCH CHARSET UTF-8 SUBJECT {%i}\r\n\x53\x70\xc3
\xbc\x6c\x6d\x61\x73\x63\x68\x69\x6e\x65", strlen("\x53\x70\xc3\xbc\x6c\x6d
\x61\x73\x63\x68\x69\x6e\x65"));
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, strSearchString); //returns
CURLE_URL_MALFORMAT

Have someone any ideads ?

Best regards

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2018-05-15