-
Notifications
You must be signed in to change notification settings - Fork 13.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Gunicorn raise encoding error #7010
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7010 +/- ##
==========================================
+ Coverage 64.46% 67.39% +2.92%
==========================================
Files 421 422 +1
Lines 20521 23902 +3381
Branches 2245 2478 +233
==========================================
+ Hits 13229 16108 +2879
- Misses 7165 7665 +500
- Partials 127 129 +2
Continue to review full report at Codecov.
|
@@ -320,7 +320,8 @@ class CsvResponse(Response): | |||
""" | |||
Override Response to take into account csv encoding from config.py | |||
""" | |||
charset = conf.get('CSV_EXPORT').get('encoding', 'utf-8') | |||
_charset = conf.get('CSV_EXPORT').get('encoding', 'utf-8') | |||
charset = 'utf-8' if _charset.lower() == 'utf-8-sig' else _charset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of interest why are you using the utf-8-sig
encoding rather than utf-8
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utf-8-sig is utf-8 encoding with BOM, and this is microsoft Excel detect utf-8 encoding.
In this scenarios, if use Excel open to east asian charset by Excel without BOM, excel show garbled.
according to:
#5377
benoitc/gunicorn#1778
on Python3 gunicorn encoding header by ascii, not support 'utf-8-sig' charset,
, so we need replace utf-8-sig charset for header encoding