Skip to content
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

keysyms: Require only 5 bytes for UTF-8 encoding #489

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

wismill
Copy link
Member

@wismill wismill commented Jul 12, 2024

Require only 5 bytes for the buffer of xkb_keysym_to_utf8, as UTF-8 encodes code points on up to 4 bytes + 1 byte for the NULL-terminating byte.

Previous standard RFC 2279 (1998) required up to 6 bytes per code point, but has been superseded by RFC 3629 (2003).

Note that the commit e052429 that introduced this API is from 2012, which is 9 years after the new standard was introduced.

This PR modifies quite a lot of files (but with tiny diff), because we now enforce to use minimal buffer size internally.

Tests were already added in #414.

Fixes #418

Copy link
Contributor

@whot whot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems correct :)

Require only 5 bytes for the buffer of `xkb_keysym_to_utf8`, as UTF-8
encodes code points on up to 4 bytes + 1 byte for the NULL-terminating
byte.

Previous standard [RFC 2279] (1998) required up to 6 bytes per code
point, but has been superseded by [RFC 3629] (2003).

[RFC 2279]: https://datatracker.ietf.org/doc/html/rfc2279
[RFC 3629]: https://datatracker.ietf.org/doc/html/rfc3629
@wismill wismill force-pushed the keysyms/utf-8-bytes-count branch from 307eb78 to 3fda209 Compare July 22, 2024 06:47
@wismill wismill merged commit addf73c into xkbcommon:master Jul 22, 2024
4 checks passed
@wismill wismill deleted the keysyms/utf-8-bytes-count branch July 22, 2024 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

xkb_keysym_to_utf8() requires output buffer size to be at least 7, but it should be 5
2 participants