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 UTF-32 BOM #8403
Fix UTF-32 BOM #8403
Conversation
The UTF-32 BOM is `0000feff`, not `0000ffff`
|
it's important to sort the entries so that longer BOMs are first, otherwise a UTF16 BOM will 'hide' a UTF32 BOM (since they start with the same bytes)
"ffff0000".decodeHex(), | ||
) | ||
"fffe0000".decodeHex(), | ||
).sortedByDescending { it.size } |
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.
Please use an explicit order. Arbitrarily sorting breaks the indices used on the matching side, which will also need changed to match the new order.
Thank you for explaining, I see the problem and the explanation is clear. I fixed the same problem in my project by sorting the options by length, but that's only because I'm using TypedOptions. I don't really have time to fix it and the indices here. Would someone else mind picking it up? I've enabled "Allow edits by maintainers", or feel free to open a new PR with this one as inspiration. |
I'd like to open a new PR. Should I pick up the one in square/wire as well? |
Be my guest! |
Continued in #8407 |
The UTF-32 BOM is
0000feff
, not0000ffff
https://en.wikipedia.org/wiki/Byte_order_mark#Byte-order_marks_by_encoding
Noticed by @JakeWharton in kotlinlang Slack
See also: square/wire#2935