Flask response with Arabic text is not readable

℡╲_俬逩灬. 提交于 2020-02-08 10:02:28

问题


i want send arabic words with ajax:

client side:

 $.ajax({
        data: {
              TblName: TblName,
            ID:ID,
            NewName:"اسم المستخدم موجود بالفعل"
        },
        type: 'POST',

        url: '/edit'  
                })
.done(function (data) {...

server side(flask):

@app.route('/EditName',methods=['POST'])   
def EditName():
    ID = request.form['ID']
    NewNameAfterEdit = request.form['NewName']
    print(NewNameAfterEdit ) #  ans is ??????

When I send Arabic text it is not properly encoded, it returns ?????????? but when I send english text, everything is ok. When I print NewNameAfterEdit I get ???? .

print(NewNameAfterEdit ) # ans is ??????

How can I solve it?


回答1:


Just set flask's configuration JSON_AS_ASCII, to False.



来源:https://stackoverflow.com/questions/59956151/flask-response-with-arabic-text-is-not-readable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!