mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-27 05:43:09 +00: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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user