簡體   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