mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 11:51:26 -07:00
csv module utils: detect unicode BOM in content (#6662)
* csv module utils: detect unicode BOM in content * fix handling of py2 * fix comment * add changelog frag * add missing link * simplification
This commit is contained in:
parent
9395df1c6f
commit
bb2169340d
4 changed files with 50 additions and 13 deletions
|
@ -55,8 +55,10 @@ def initialize_dialect(dialect, **kwargs):
|
|||
|
||||
|
||||
def read_csv(data, dialect, fieldnames=None):
|
||||
|
||||
BOM = to_native(u'\ufeff')
|
||||
data = to_native(data, errors='surrogate_or_strict')
|
||||
if data.startswith(BOM):
|
||||
data = data[len(BOM):]
|
||||
|
||||
if PY3:
|
||||
fake_fh = StringIO(data)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue