-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
EscapeString #440
base: master
Are you sure you want to change the base?
EscapeString #440
Conversation
Role string `json:"role"` | ||
Content string `json:"content"` | ||
Role string `json:"role"` | ||
Content EscapeString `json:"content"` |
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 you adopt a method that doesn't involve breaking changes?
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 am not very familiar with other implementation methods.
Hey, thank you for the PR! Could you please provide an illustration where default Go's string handling doesn't work? And what could be our alternatives here? |
when there are Emoji in string, Marshal would fail:
for example, 😗 will be quoted to ASCII \U0001f617 , but it is not valid in json (encoding/json/scanner.go:353). |
I find that in python, json.dumps encode that Emoji to \ud83d\ude17. So strange |
hack as func (esc EscapeString) MarshalJSON() ([]byte, error) { |
The official Python package, when converting objects to JSON strings, will convert Chinese and other text into Unicode encoding, and can effectively avoid sensitive words in responses. This modification is to enable the Golang package to have this capability.