[PATCH v2 14/20] nmbug-status: Encode output using the user's locale
W. Trevor King
wking at tremily.us
Mon Feb 10 10:40:35 PST 2014
Instead of always writing UTF-8, allow the user to configure the
output encoding using their locale. This is useful for previewing
output in the terminal, for poor souls that don't use UTF-8 locales
;).
---
devel/nmbug/nmbug-status | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index 873a46a..040baf0 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -88,7 +88,7 @@ class Page (object):
byte_stream = sys.stdout.buffer
except AttributeError: # Python 2
byte_stream = sys.stdout
- stream = codecs.getwriter(encoding='UTF-8')(stream=byte_stream)
+ stream = codecs.getwriter(encoding=_ENCODING)(stream=byte_stream)
self._write_header(views=views, stream=stream)
for view in views:
self._write_view(database=database, view=view, stream=stream)
@@ -230,7 +230,7 @@ _PAGES['html'] = HtmlPage(
header='''<!DOCTYPE html>
<html lang="en">
<head>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv="Content-Type" content="text/html; charset={encoding}" />
<title>Notmuch Patches</title>
</head>
<body>
@@ -238,7 +238,8 @@ _PAGES['html'] = HtmlPage(
Generated: {date}<br />
For more infomation see <a href="http://notmuchmail.org/nmbug">nmbug</a>
<h3>Views</h3>
-'''.format(date=datetime.datetime.utcnow().date()),
+'''.format(date=datetime.datetime.utcnow().date(),
+ encoding=_ENCODING),
footer='</body>\n</html>\n',
)
--
1.8.5.2.8.g0f6c0d1
More information about the notmuch
mailing list