5 def remove_tricky_unicode(x):
8 x = x.replace("\u2018", "'").replace("\u2019", "'")
9 x = x.replace("\u201c", '"').replace("\u201d", '"')
10 x = x.replace("\u2e3a", "-").replace("\u2014", "-")
17 def __init__(self, filename):
18 self.full_filename = os.path.join(constants.pages_dir, filename)
19 self.f = open(self.full_filename, "wb")
20 self.xforms = [remove_tricky_unicode]
22 def add_xform(self, xform):
23 self.xforms.append(xform)
25 def write(self, data):
26 for xform in self.xforms:
28 self.f.write(data.encode("utf-8"))
41 # fw = file_writer("test")
42 # fw.add_xform(toupper)
43 # fw.write(u"This is a \u201ctest\u201d. \n")