-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
UnicodeEncodeError #6895
Comments
Hi @agusmakmun. This should be fixed by #6633. Upgrade to v3.10 and let us know if the issue persists. |
My mistake - I looked too briefly with the git blame and misunderstood what the PR was doing. I'm not that familiar with unicode's surrogate pairs, but as best I can tell the presence of a surrogate is an indication that something has gone wrong. Your string should contain the unicode character itself, not its surrogates. You should probably figure out why you're getting surrogates to begin with and fix the issue there, however, you can also use the >>> '\ud83d\ude4f'.encode('utf-16', 'surrogatepass').decode('utf-16')
'🙏' Note that surrogates should exist as pairs, and it looks like your string contains a lone high surrogate, so this workaround may not work for you. >>> '\ud83d'.encode('utf-16', 'surrogatepass').decode('utf-16')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'utf-16-le' codec can't decode bytes in position 2-3: unexpected end of data More info: |
@agusmakmun did you manage to reproduce how the client was able to produce JSON containing character 0xD83D? Did you see #7026? |
Ach, I reread your issue and saw that parsing isn't failing. |
The text was updated successfully, but these errors were encountered: