[英]How to output Chinese in HTML file
我有一個表單,並在數據庫中插入一些中文單詞,沒關系。 表字符集是UTF8。 當我選擇此數據並通過郵件將其作為HTML附件發送時,會出現問題。 然后,中文不能正常顯示。 如何通過郵件發送數據之前修復charset? 我應該使用一些標題,它會工作嗎?
我的代碼看起來像這樣:
//$attachedBodyContent is data from database that contains some chinese words Mail::send( "emails.applicationTemplate", $data, function($message) use ($data, $template, $subject, $attachedBodyContent) { $message->to($data['email'], $data['name']) ->from($template['from'],$template['from_name']) ->subject($subject) ->attachData($attachedBodyContent,'YourApplicationData.html'); } );
當您生成.html附加文件時,您應該包含在<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
在這種情況下,您可以使用此代碼將您的內容與<head>
合並
<?php
$header = '<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>';
$footer = '</body>
</html>';
$allContent = $header.$attachedBodyContent.$footer;
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
這應該這樣做,進一步的信息檢查鏈接。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.