[scripts] Going to utf-8

This commit is contained in:
Pierre-Elliott Bécue 2013-05-04 19:19:36 +02:00
parent c4a19a88ed
commit a1bf0a4547
54 changed files with 676 additions and 573 deletions

View file

@ -14,7 +14,7 @@ format_sender et send_email adaptés depuis /usr/scripts/impression/crans_backen
import re
def format_sender(sender, header_charset='ISO-8859-15'):
def format_sender(sender, header_charset='utf-8'):
"""
Check and format sender for header.
"""
@ -42,8 +42,8 @@ def send_email(sender, recipient, subject, body, server='localhost', cc=None, de
Only the real name part of sender and recipient addresses may contain
non-ASCII characters. The email will be properly MIME encoded.
The charset of the email will be the first one out of US-ASCII, ISO-8859-15
and UTF-8 that can represent all the characters occurring in the email.
The charset of the email will be the first one out of US-ASCII or UTF-8
that can represent all the characters occurring in the email.
Argument server maybe a string, indicating the name of the SMTP server, or
directly an instance of smtplib.SMTP.
@ -57,10 +57,10 @@ def send_email(sender, recipient, subject, body, server='localhost', cc=None, de
# Header class is smart enough to try US-ASCII, then the charset we
# provide, then fall back to UTF-8.
header_charset = 'ISO-8859-15'
header_charset = 'UTF-8'
# We must choose the body charset manually
for body_charset in 'US-ASCII', 'ISO-8859-15', 'UTF-8':
for body_charset in 'US-ASCII', 'UTF-8':
try:
body.encode(body_charset)
except UnicodeError: