mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
py3: write unicode bom without using bytes() type
Since the file is opened in utf-8 mode, it needs to be written to using unicode text, not a b'' string. In python3, '\xef\xbb\xbf' becomes '' which is definitely not a BOM. Writing the unicode escaped codepoint allows the codecs.open() encoding to correctly choose the right bytes for the BOM and insert it as needed.
This commit is contained in:
parent
670c5ebe6a
commit
d78e4807c3
@ -107,7 +107,7 @@ class CSV_XML(CatalogPlugin):
|
||||
outfile = codecs.open(path_to_output, 'w', 'utf8')
|
||||
|
||||
# Write a UTF-8 BOM
|
||||
outfile.write('\xef\xbb\xbf')
|
||||
outfile.write(u'\ufeff')
|
||||
|
||||
# Output the field headers
|
||||
outfile.write(u'%s\n' % u','.join(fields))
|
||||
|
Loading…
x
Reference in New Issue
Block a user