简体   繁体   中英

how to encode string to utf8 inside html

I'm trying to use awdeoroi mailmerge. In the html template i have french encoded characters in paragraph tags. When i execute the mailing i have encoding errors:

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

How to encode those paragraph so that they are well treated in 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>

Hex f4 is latin1 for ô . If this was typed into Python, you needed this at the start of the source file:

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

If the data is coming from a database, please provide some more details.

If the text is coming from somewhere else, please provide some more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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