xkbcommon / libxkbcommon

keymap handling library for toolkits and window systems
https://xkbcommon.org
Other
286 stars 125 forks source link

xkbcli how-to-type: Enhance arguments parsing & doc #505

Closed wismill closed 2 months ago

wismill commented 2 months ago

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:

Fixed the issues above:

wismill commented 2 months ago

Hmm the use of strtol with base 0 parses strings starting with 0 as octal numbers. We should probably strip leading zeros to parse only decimal and hexadecimal numbers. It’s too easy to copy a Unicode code point from the standard format (e.g. U+0061) and get unexpected result.

wismill commented 2 months ago

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.

wismill commented 2 months ago

Note that we could go further and try to parse a keysym name without the --keysym flag, if previous attempts to parse as a code point / plain character failed. Maybe a new flag --codepoint would be useful then for completeness.