mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-23 19:01:26 -07:00
[PR #6662/bb216934 backport][stable-6] csv module utils: detect unicode BOM in content (#6694)
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
(cherry picked from commit bb2169340d
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
e1f4be1e01
commit
59999a89f1
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