0
我正在製作支持多種語言的C程序。該程序使用WCHAR類型而不是字符發送電子郵件。問題是,當我收到的電子郵件和讀它,一些字符無法正確顯示,還有一些英文的像E,M,...這是一個例子:Unicode字符顯示不正確
<!-- language: lang-c -->
curl_easy_setopt(hnd, CURLOPT_READFUNCTION, payload_source);
curl_easy_setopt(hnd, CURLOPT_READDATA, &upload_ctx);
static const WCHAR *payload_text[]={
L"To: <[email protected]>\n",
L"From: <[email protected]>(Example User)\n",
L"Subject: Hello!\n",
L"\n",
L"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 WCHAR *data;
if ((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) {
return 0;
}
data = payload_text[upload_ctx->lines_read];
if (data) {
size_t len = wcslen(data);
memcpy(ptr, data, len);
upload_ctx->lines_read ++;
return len;
}
return 0;
}
你用什麼樣的環境和編譯器? – AlexLordThorsen 2012-08-10 18:14:02
另外,e和m是什麼樣子?他們有沒有重點超過正常字符? – AlexLordThorsen 2012-08-10 18:15:00