Skip to content

Commit 017b6bd

Browse files
committed
Use REDASH_CSV_WRITER_ENCODING for downloading CSV
1 parent 544e7f6 commit 017b6bd

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

redash/handlers/query_results.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import unicodedata
23
from urllib.parse import quote
34

@@ -35,6 +36,7 @@
3536
to_filename,
3637
)
3738

39+
WRITER_ENCODING = os.environ.get("REDASH_CSV_WRITER_ENCODING", "utf-8")
3840

3941
def error_response(message, http_status=400):
4042
return {"job": {"status": 4, "error": message}}, http_status
@@ -380,8 +382,8 @@ def make_json_response(query_result):
380382

381383
@staticmethod
382384
def make_csv_response(query_result):
383-
headers = {"Content-Type": "text/csv; charset=UTF-8"}
384-
return make_response(serialize_query_result_to_dsv(query_result, ","), 200, headers)
385+
headers = {"Content-Type": f"text/csv; charset={WRITER_ENCODING.upper()}"}
386+
return make_response(serialize_query_result_to_dsv(query_result, ",").encode(WRITER_ENCODING), 200, headers)
385387

386388
@staticmethod
387389
def make_tsv_response(query_result):

0 commit comments

Comments
 (0)