#34642: File.open to support different encodings
----------------------------------------+------------------------
Reporter: liori | Owner: nobody
Type: New feature | Status: new
Component: Core (Other) | Version: dev
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+------------------------
Currently the
[https://github.com/django/django/blob/main/django/core/files/base.py#L108
File.open] method has only a single parameter `mode`. `mode` can suggest
opening a file in text mode. Then, Python's `open` will by default attempt
to use the common utf-8 encoding.
It is a common pattern in a code base I work on to use the `utf-8-sig`
encoding for CSV files, as this provides a slight improvement to user
experience when opening the file in Excel. Right now, to create a file in
this encoding using Django's File, we have to open it in a binary mode and
explicitly wrap the file handle in a codec. It would be helpful if, just
like the base Python's `open` function, `File.open` also accepted an
`encoding` parameter, and pass it to the Python's `open` function.
--
Ticket URL: <https://code.djangoproject.com/ticket/34642>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701889a80a82f-a5884705-5599-446c-b2df-6f9e334429a1-000000%40eu-central-1.amazonses.com.