繁体   English   中英

如何在 html 中将字符串编码为 utf8

[英]how to encode string to utf8 inside html

我正在尝试使用 awdeoroi 邮件合并。 在 html 模板中,我在段落标签中有法语编码字符。 当我执行邮件时,我有编码错误:

UnicodeDecodeError : 'utf-8' codec can't decode byte 0xf4 in position 81: invalid continuation byte

如何对这些段落进行编码,以便在 python 中得到很好的处理?

TO: {{email}}
SUBJECT: Testing mailmerge
FROM: My Self <myself@mydomain.com>
Content-Type: text/html

<html>
<body>

<p>Hi, {{name}},</p>

<p>Your number is {{number}}.</p>

<p>Sent by <a href="https://github.com/awdeorio/mailmerge">Here is the paragraph. Ce texte est en francais. <b>Accentué<b>. L'ideal</a></p>

</body>
</html>

十六进制f4ô的 latin1 。 如果这是在 Python 中输入的,则您需要在源文件的开头这样做:

# -*- coding: utf-8 -*-

如果数据来自数据库,请提供更多详细信息。

如果文本来自其他地方,请提供更多详细信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM