1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
From adb0929f0db4da533a9d5b317e6f49a91feb3b3e Mon Sep 17 00:00:00 2001
From: Stanislav Ochotnicky <sochotnicky@redhat.com>
Date: Tue, 3 Dec 2013 18:03:13 +0100
Subject: [PATCH] [a2x] Write manifests in UTF-8 by default
This is a workaround for rhbz#968308 where a2x tries to write non-ASCII content
epub manifest. Since the write_file is mostly used to write xml content which
defaults to UTF-8 this seems fairly safe
---
a2x.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/a2x.py b/a2x.py
index 1b192a2..ad163e3 100755
--- a/a2x.py
+++ b/a2x.py
@@ -21,6 +21,7 @@ import urlparse
import zipfile
import xml.dom.minidom
import mimetypes
+import codecs
PROG = os.path.basename(os.path.splitext(__file__)[0])
VERSION = '8.6.8'
@@ -144,8 +145,8 @@ def find_executable(file_name):
result = _find_executable(file_name)
return result
-def write_file(filename, data, mode='w'):
- f = open(filename, mode)
+def write_file(filename, data, mode='w', encoding='utf-8'):
+ f = codecs.open(filename, mode, encoding)
try:
f.write(data)
finally:
--
1.8.4.2
|