cleaner way to get rid of BOM for CsvPage
This commit is contained in:
parent
a6a7130b31
commit
977f5a9f02
1 changed files with 4 additions and 1 deletions
|
|
@ -345,9 +345,12 @@ class CsvPage(Page):
|
|||
"""
|
||||
|
||||
def build_doc(self, content):
|
||||
# We may need to temporarily convert content to utf-8 because csv
|
||||
# does not support Unicode.
|
||||
encoding = self.encoding
|
||||
if encoding == 'utf-16le':
|
||||
content = content.decode('utf-16le')[1:].encode('utf-8')
|
||||
# If there is a BOM, decode('utf-16') will get rid of it
|
||||
content = content.decode('utf-16').encode('utf-8')
|
||||
encoding = 'utf-8'
|
||||
if self.NEWLINES_HACK:
|
||||
content = content.replace('\r\n', '\n').replace('\r', '\n')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue