[英]UTF-8 Spanish Characters Not Displaying
我拼命嘗試讓西班牙語字符正確顯示在我發送的MIME電子郵件中。
因此,經過幾個小時的搜索,我嘗試了以下操作,但均未成功。
在我的PHP中添加了以下內容:
mb_internal_encoding("UTF-8"); header('Content-Type: text/html; charset=utf-8');
確保我的文件在notepad ++中為UTF8
在我的HTML代碼中添加了以下內容:
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
將以下內容添加到my.cnf文件中,然后重新啟動服務器:
init-connect='SET NAMES utf8'
確保所有表都在utf8_unicode_ci中
在選擇查詢之前,向查詢中添加了以下內容:
SET NAMES utf8;
我正在使用mime發送帶有以下代碼的電子郵件:
// Creating the Mime message $mime = new Mail_mime($crlf); // Setting the body of the email $mime->setTXTBody($body); $mime->setHTMLBody($html); $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject, "Content-Type: text/html;charset=utf-8"); $smtp = Mail::factory('smtp', array ('host' => $host, 'port' => $port, 'auth' => true, 'username' => $username, 'password' => $password)); $body = $mime->get(); $headers = $mime->headers($headers); $recipients = $to.", ".$bcc; $mail = $smtp->send($recipients , $headers, $body);
我希望有人可以指出正確的方向。
問題很簡單:使用西班牙語時UTF-8很爛,您必須使用8859-15。
UTF-8主要用於英語,即使英語使用的是拉丁數字和Julious Ceasar和羅馬帝國的義務,創作者也不在乎拉丁語言(真的很有趣),並聲稱它已支持國際HTML5,所有這些廢話。
也許創作者的世界僅限於美國,這就是他們對世界的了解。 但是外面的世界越來越大,我希望他們理解這一點,並且會推出新的UTF-9 ...
甚至HTML5驗證程序也認為:
Legacy encoding iso-8859-15 used. Documents should use UTF-8.
現在,如果要在超級專業國際標准UTF-8中使用西班牙語,則必須遵循以下條件:
像這樣編碼每個符號,否則將不起作用:
á -> á
é -> é
í -> í
ó -> ó
ú -> ú
ñ -> ñ
誰創造了UTF-8?
我想通了。 啞劇電子郵件出現問題。
// Creating the Mime message
$mime = new Mail_mime($crlf);
// Setting the body of the email
$mime->setTXTBody($body);
$mime->setHTMLBody($html);
$mimeparams=array();
$mime->addAttachment($filename,'application/pdf');
//set SMTP server details - Using keys from www.protectedtrust.com
$port = "25";
$host = "in.mailjet.com";
$username = "fcb0ee027e8cc30b1a47caf9c6272db1";
$password = "fe80add357c21cae0133632c4c25177a";
//prepare message elements and send
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject,
'Content-Type' => "text/html;charset=utf-8",
'MIME-Version' => '1.0',
'Content-Transfer-Encoding' => '8bit'
);
$mimeparams['text_encoding']="8bit";
$mimeparams['text_charset']="UTF-8";
$mimeparams['html_charset']="UTF-8";
$mimeparams['head_charset']="UTF-8";
$body = $mime->get($mimeparams);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$body = $mime->get();
$headers = $mime->headers($headers);
$recipients = $to.", ".$bcc;
$mail = $smtp->send($recipients , $headers, $body);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.