Set ensure_ascii=False on json.dumps() for WebSocket.send_json()#2341
Set ensure_ascii=False on json.dumps() for WebSocket.send_json()#2341Kludex merged 3 commits intoKludex:masterfrom
ensure_ascii=False on json.dumps() for WebSocket.send_json()#2341Conversation
|
I think we have some issues about this around. Can we link them here? |
|
I'm not sure what problem you encountered that requires adding this option. Sending Chinese should still work fine without using this option. Can you provide a more detailed description of what kind of problem this solves? (Converting Chinese to Unicode encoding is not a problem, it is standard-compliant.) |
|
Yes, from the perspective of the code workflow, there is no problem. I am building a Chinese question and answer system, but when using |
abersheeran
left a comment
There was a problem hiding this comment.
I verified it, and it was
Kludex
left a comment
There was a problem hiding this comment.
Yeah, according to the spec (https://asgi.readthedocs.io/en/latest/specs/www.html#send-send-event), there was no need to ensure_ascii here. 👍
ensure_ascii=False on json.dumps() for WebSocket.send_json()
ensure_ascii=False on json.dumps() for WebSocket.send_json()json.dumps(..., ensure_ascii=False) for WebSocket.send_json()
json.dumps(..., ensure_ascii=False) for WebSocket.send_json()json.dumps(..., ensure_ascii=False) on WebSocket.send_json()
json.dumps(..., ensure_ascii=False) on WebSocket.send_json()ensure_ascii=False on WebSocket.send_json()
ensure_ascii=False on WebSocket.send_json()ensure_ascii=False on json.dumps() for WebSocket.send_json()
Summary
When the data output by the
send_jsonfunction is in Chinese, it will force Chinese characters to be converted to Unicode, so I fixed this issue.(The most fundamental reason is that the value of theensure_asciiparameter was not modified when using thejson.dumpsfunction)Checklist