'I want to return response to download CSV file from data frame contains Arabic letters

I have encountered a problem while coding using Flask for my website I have a CSV file that I converted to Dataframe then I want to return it as CSV to the user so they can download it.

however, when I do that the Arabic letters do not show clearly only symbols :( I tried different possible ways but unfortunately, all doesn't work

@flask_app.route('/getPlotCSV')
def download_file():
    path ="marked_test_df.csv"
    #path.encode('utf-8-sig')
    try:
        df = pd.read_csv(path, encoding='utf-8-sig')
        df_ob= df.to_csv(encoding='utf-8-sig')
        resp = make_response(df_ob)
        resp.headers["Content-Disposition"] = "attachment; filename=marked_test_df.csv "
        #resp.charset='utf-8-sig'
        #resp.iter_encoded='utf-8-sig'
        resp.headers["Content-Type"] = "text/csv ; charset = utf-16"
        resp.content_encoding = 'utf-16'
        os.remove(path)
    except Exception as error:
        flask_app.logger.error("Error removing or closing downloaded file handle", error)

    return resp

sample of the CSV before the user can download it:

However, when the user downloads it through the download button it shows like that:



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source