-
Notifications
You must be signed in to change notification settings - Fork 124
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
xkbcli how-to-type: Enhance arguments parsing & doc #505
Conversation
Hmm the use of |
d14bf67
to
9d4f1bf
Compare
51c102a
to
71938d6
Compare
A big part of the new code is about UTF-8 to UTF-32 decoding. It’s kept as an internal API for now. I added the related tests. |
Note that we could go further and try to parse a keysym name without the |
Add internal functions to convert UTF-32 to UTF-8, with corresponding tests.
Currently the positional parameter of the CLI is either a Unicode code point or a keysym. However their respective format is not documented. It turns out that there are multiple issues due to the use of `strtol`: - Code points can be parsed as octal, decimal and hexadecimal, while keysyms can only be parsed as hexadecimal. Some programs outputs keysyms in their decimal form (e.g. `wev`) so it is worth to bring symmetry with code points. - Octal format is unusual for both and is triggered by leading zeros, which is unintuitive in this context. - `U+NNNN` format is the standard format for Unicode code points but is not supported. - Plain characters are not supported, e.g.: a, é, ß, Æ, γ, 🦆, etc. Although this is probably the easiest format for most users. Fixed the issues above: - Allow the code point to be passed exactly in the following formats: - Literal character (requires UTF-8 character encoding of the terminal); - Decimal number; - Hexadecimal number: either `0xNNNN` or `U+NNNN` (any digit count) - Allow the keysym to be passed exactly in the following formats: - Decimal number; - Hexadecimal number: `0xNNNN` (any digit count); - Name. - Improve both `--help` message and manual page.
71938d6
to
423b7c5
Compare
Currently the positional parameter of the CLI is either a Unicode code
point or a keysym. However their respective format is not documented.
It turns out that there are multiple issues due to the use of
strtol
:keysyms can only be parsed as hexadecimal. Some programs outputs
keysyms in their decimal form (e.g.
wev
) so it is worth to bringsymmetry with code points.
which is unintuitive in this context.
U+NNNN
format is the standard format for Unicode code points but isnot supported.
Although this is probably the easiest format for most users.
Fixed the issues above:
0xNNNN
orU+NNNN
.0xNNNN
;--help
message and manual.