问题描述:

I'm trying to send a django email with UTF-8 characters in the template, specifically:

S'il vous plaît

I get the error:

UnicodeDecodeError: 'utf8' codec can't decode byte 0x94 in position 147: unexpected code byte

When trying to encode the special "î" character (that is the character at that position.)

Here is my code for generating the email body:

template = loader.get_template('french_thank_you.html')

网友答案:

The editor you're using has saved the file using Mac Roman encoding. Open the template, re-save it as UTF-8, and it should work fine.

网友答案:

0x94 is not part of î in UTF-8. The UTF-8 encoding for î is 0xc3 0xae.

相关阅读:
Top