Download attachments plain text encoding 'ANSI'

15 views
Skip to first unread message

Marchi

unread,
Jul 17, 2020, 1:29:06 AM7/17/20
to Django users
Hi,

I hope the encoding type of the download plintext file is ANSI, not UTF-8.

View.py

...
with open(file_path + filename, 'r', encoding='cp949') as fd:
    # This plain text file from inside the server is an ANSI (cp949) encoded file.
    response = HttpResponse(fd) 
    response['Content-Type'] = "text/plain" 
    response['Content -Disposition'] = "attachment; filename=%s" % filename​

return response
...

When text file is downloaded from chromium-based browser, it is downloaded as autf-8 encoding text file.

How can I modify the web server(views.py) to download as an ANSI (CP949) encoded text file?

Best Regards



Reply all
Reply to author
Forward
0 new messages