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
Fix printing of 4 byte UTF-8 characters #1537
Conversation
buffer.push(code); | ||
if (code > 191 && code < 224) { | ||
if (((code & 0xE0) ^ 0xC0) == 0) { // 110xxxxx |
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.
As a (micro(?)-)optimization, could this be written as if ((code & 0xE0) == 0xC0), and the same for the check below on line 404? That would save an xor.
Please rebase on incoming, so the diff here contains just your new code. |
Yeah, sorry about that, sometimes I love git and sometimes it cheerfully permits me to screw myself over...let me see if I can unpick this mess... |
Right, fixed. @juj wasn't too concerned about performance but I do think it's semantically clearer so I like. |
I don't really understand this or utf ;) but looks good and if the previous test passes + a new testcase now works, then excellent. thanks! |
Fix printing of 4 byte UTF-8 characters
Carrying on from the original issue reported at #1382 where I screwed up the conversion to a PR, here is a clean set of commits ready to be pulled.
The only test I ran was
python tests/runner.py test_utf
.