html联系人表单和通过meta标记的utf8编码存在奇怪的编码问题

html联系人表单和通过meta标记的utf8编码存在奇怪的编码问题,html,forms,unicode,utf-8,Html,Forms,Unicode,Utf 8,我有一个简单的联系方式: <form id="emailForm" action="contact.php" method="POST"> <label for="name">Your name</label> <input type="text" id="name" name="name"> <label for="email">Your email</label> <input t

我有一个简单的联系方式:

<form id="emailForm" action="contact.php" method="POST">
    <label for="name">Your name</label>
    <input type="text" id="name" name="name">

    <label for="email">Your email</label>
    <input type="text" id="email" name="email">

    <label for="subject">Subject</label>
    <input type="text" id="subject" name="subject">

    <label for="message">Message</label>
    <textarea id="message" name="message"></textarea>

    <p class="emailPop" id="emailError"></p>

    <input id="submit" type="submit" value="Send">
</form>

下面是一个例子:如果我通过我的页面发送消息

如果我通过没有
的测试页面发送相同的消息:

结果如下:

正如您所看到的,没有meta标记的页面实际上给出了正确的字符


这个问题出现在Google Chrome和Firefox中。

去掉身体和主题的
utf8\u编码
!当您的数据来自浏览器时,它已经在UTF-8中,您不需要将其从拉丁语-1转换为UTF-8(这是
utf8\u encode
所做的)

您还应向消息中添加指定其编码的适当标题:

'headers' => 'From: "' . $data['name'] . '" <' . $data['email'] . ">\r\n" .
             "MIME-Version: 1.0\r\n" .
             'Content-type: text/plain; charset=utf-8'

'headers'=>'From:“.$data['name']”这是关于您的电子邮件发送机制,而不是您的表单。不,不是。从没有meta标记的页面发送消息会导致一封正常的电子邮件。添加元标记时,这些符号会出现。您始终需要指定某些内容的编码方式。您需要设置元信息,以告知浏览器使用哪种编码来解释文本,以及应该使用哪种编码将文本发送到服务器。电子邮件也是如此,您需要设置标题,告诉电子邮件客户端邮件的编码方式。所以,这一切都是关于你如何准确地发送电子邮件!我已经用一个例子更新了这个问题,请检查一下。是的,我们得到了这个问题。请向我们显示发送电子邮件的代码。
'headers' => 'From: "' . $data['name'] . '" <' . $data['email'] . ">\r\n" .
             "MIME-Version: 1.0\r\n" .
             'Content-type: text/plain; charset=utf-8'