-
-
Notifications
You must be signed in to change notification settings - Fork 930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set ensure_ascii=False
on json.dumps()
for WebSocket.send_json()
#2341
Conversation
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I verified it, and it was
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a test case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_json
function 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_ascii
parameter was not modified when using thejson.dumps
function)Checklist