src/keysym-utf.c


Log

Author Commit Date CI Message
Jaroslaw Kubik 0345aba0 2020-02-12T23:44:42 Support translation Unicode codepoints to keysyms In order to support features like auto-type and UI automation, the relevant tools need to be able to invert the keycode->keysym->text transformation. In order to facilitate that, a new API was added. It allows querying the keysyms that correspond to particular Unicode codepoints. For all practical purposes, it can be thought of as an inverse of xkb_keysym_to_utf32().
Ran Benita 40aab05e 2019-12-27T13:03:20 build: include config.h manually Previously we included it with an `-include` compiler directive. But that's not portable. And it's better to be explicit anyway. Every .c file should have `include "config.h"` first thing. Signed-off-by: Ran Benita <ran@unusedvar.com>
Ran Benita 5cee660f 2018-06-23T22:00:19 keysym-utf: reject out-of-range Unicode codepoints in xkb_keysym_to_utf{8,32} It used to be UTF-8 was defined for inputs > 0x10FFFF, but nowadays that's the maximum and a codepoint is encoded up to 4 bytes, not 6. Fixes: https://github.com/xkbcommon/libxkbcommon/issues/58 Fixes: https://github.com/xkbcommon/libxkbcommon/issues/59 Reported-by: @andrecbarros Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita b63196e9 2018-02-27T20:24:57 keysym-utf: replace the Unicode characters for leftanglebracket and rightanglebracket Looking at leftanglebracket - The standard[1] does not specify any Unicode value for it. - The keysym list keysymdef.h in x11proto[2] says U+27E9 MATHEMATICAL RIGHT ANGLE BRACKET in a comment. - The keysym->unicode list in xkbcommon which comes from [3] has U+2329 LEFT-POINTING ANGLE BRACKET. - The keysym->unicode list in Xlib[4] has U+2039 SINGLE LEFT-POINTING ANGLE QUOTATION MARK. [1] https://www.x.org/releases/X11R7.7/doc/xproto/x11protocol.html#Legacy_KEYSYMs [2] https://cgit.freedesktop.org/xorg/proto/x11proto/tree/keysymdef.h [3] https://www.cl.cam.ac.uk/%7Emgk25/ucs/keysym2ucs.c [4] https://cgit.freedesktop.org/xorg/lib/libX11/tree/src/xlibi18n/imKStoUCS.c The symbols we are using, {LEFT,RIGHT}-POINTING ANGLE BRACKET, are deprecated according to Unicode[5]: These characters are deprecated and are strongly discouraged for mathematical use because of their canonical equivalence to CJK punctuation. [5] https://www.unicode.org/charts/PDF/U2300.pdf Hence, switch to the MATHEMATICAL codepoints which seem to be the best fit. Fixes: https://github.com/xkbcommon/libxkbcommon/issues/47 Reported-by: @bytensky Signed-off-by: Ran Benita <ran234@gmail.com>
Matt Whitlock 0db1d313 2017-09-28T21:31:28 keysym-utf: Add missing codes for signifblank and permille keysyms
Ran Benita 2bbaf7c7 2014-02-09T13:50:21 Add utf8.{c,h} for common UTF-8 util functions We need to validate some UTF-8, so this adds an is_valid_utf8() function, which is probably pretty slow but should work correctly. Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita a088c9ba 2014-02-08T16:03:06 keysym: fix types in bin_search Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 31430670 2014-01-11T16:40:42 Fix some cppcheck warnings Someone was nice enough to run this for us: ftp://ftp.sunet.se/pub/Linux/distributions/Debian/debian/pool/main/libx/libxkbcommon/libxkbcommon_0.3.1.orig.tar.gz [libxkbcommon-0.3.1/src/keymap.c:86]: (style) The scope of the variable 'j' can be reduced. [libxkbcommon-0.3.1/src/keymap.c:87]: (style) The scope of the variable 'key' can be reduced. [libxkbcommon-0.3.1/src/keysym-utf.c:843]: (style) The scope of the variable 'mid' can be reduced. [libxkbcommon-0.3.1/src/state.c:992]: (style) The scope of the variable 'str' can be reduced. [libxkbcommon-0.3.1/src/xkbcomp/action.c:467]: (style) The scope of the variable 'absolute' can be reduced. [libxkbcommon-0.3.1/src/xkbcomp/rules.c:468]: (style) The scope of the variable 'consumed' can be reduced. [libxkbcommon-0.3.1/src/xkbcomp/rules.c:862]: (style) The scope of the variable 'mlvo' can be reduced. [libxkbcommon-0.3.1/src/xkbcomp/rules.c:863]: (style) The scope of the variable 'kccgst' can be reduced. [libxkbcommon-0.3.1/src/xkbcomp/rules.c:865]: (style) The scope of the variable 'match_type' can be reduced. [libxkbcommon-0.3.1/src/xkbcomp/symbols.c:753]: (style) The scope of the variable 'toAct' can be reduced. [libxkbcommon-0.3.1/src/xkbcomp/symbols.c:1573]: (style) The scope of the variable 'key' can be reduced. [libxkbcommon-0.3.1/test/common.c:80]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. [libxkbcommon-0.3.1/test/interactive.c:358]: (style) The scope of the variable 'nevs' can be reduced. [libxkbcommon-0.3.1/test/interactive.c:236]: (style) Checking if unsigned variable 'nsyms' is less than zero. [libxkbcommon-0.3.1/test/interactive.c:226]: (style) Unused variable: unicode Signed-off-by: Ran Benita <ran234@gmail.com>
Siddharth Heroor 27f2743c 2013-10-07T14:11:36 keysym-utf: Fix a warning about shadowing Change variable names to avoid the name clash. The warning seen is src/keysym-utf.c: In function 'bin_search': src/keysym-utf.c:841: warning: declaration of 'min' shadows a global declaration src/utils.h:109: warning: shadowed declaration is here src/keysym-utf.c:842: warning: declaration of 'max' shadows a global declaration src/utils.h:115: warning: shadowed declaration is here Signed-off-by: Siddharth Heroor <heroor@ti.com>
Ran Benita d9317d5f 2012-11-05T21:50:38 keysym-utf: mark keysymtab array as static Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 7891c917 2012-11-05T21:34:59 keysym-utf: also translate special keysyms like Tab and Return The keysym2ucs.c file apparently leaves out some keysyms, which libX11 deals with separately (like in _XkbHandleSpecialSym()). The problematic keysyms are the keypad ones (for which we already added some support) and keysyms which use 0xff** instead of 0x00** < 0x20. This code should fix them properly, as much as I could gather from libX11 and http://www.cl.cam.ac.uk/~mgk25/ucs/keysym2ucs.c and other sources (which are not aware of locale). https://bugs.freedesktop.org/show_bug.cgi?id=56780 Reported-by: Gatis Paeglis <gatis.paeglis@digia.com> Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 17985511 2012-10-16T21:09:33 utils: add and use ARRAY_SIZE macro Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 239a5be1 2012-10-04T11:48:56 keysym-utf: make keysym->unicode table a bit smaller Saves a few kbytes, and unlikely to change. Signed-off-by: Ran Benita <ran234@gmail.com>
Rob Bradford de4098a0 2012-09-14T17:50:31 keysym-utf8: Optimise the keysym to utf8 lookup This change adds range checks based on the lowest keysym and highest keysym in the table. This allows a quick check to be applied to identify if the keysym is inside the table. To really give value to this optimisation the table is split to have a separate table for the keypad keysyms. The test suite passes with this change. Signed-off-by: Rob Bradford <rob@linux.intel.com>
Ran Benita b2110705 2012-09-16T14:45:32 Organize src/ and test/ headers - Add context.h and move context-related functions from xkb-priv.h to it. - Move xkb_context definition back to context.c. - Add keysym.h and move keysym upper/lower/keypad from xkb-priv.h to it. - Rename xkb-priv.h to map.h since it only contains keymap-related definitions and declarations now. - Remove unnecessary includes and some and some other small cleanups. Signed-off-by: Ran Benita <ran234@gmail.com>
Daniel Stone 14741800 2012-09-11T14:52:27 Constify keysym <-> Unicode lookup table Before: text data bss dec hex filename 234422 11288 2304 248014 3c8ce obj-amd64/.libs/libxkbcommon.so.0.0.0 After: text data bss dec hex filename 240694 5016 2304 248014 3c8ce obj-amd64/.libs/libxkbcommon.so.0.0.0 Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Ran Benita 58f8d2c1 2012-07-20T17:09:49 utils: remove Xfuncproto.h and use our own macros Add XKB_EXPORT to replace _X_EXPORT, and copy the definitions of _X_ATTRIBUTE_FOO as ATTR_FOO. Signed-off-by: Ran Benita <ran234@gmail.com>
Daniel Stone 9308a460 2012-07-17T10:20:15 Run source tree through uncrustify .uncrustify.cfg committed for future reference also, but had to manually fix up a few things: it really likes justifying struct initialisers. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 6992de40 2012-06-08T14:54:31 Add keypad sequences to UTF-8 keysym printing Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Rob Bradford e0524296 2012-06-08T13:10:28 Add API for getting unicode representation of a keysym This code uses a table and code derived from http://www.cl.cam.ac.uk/~mgk25/ucs/keysym2ucs.c The added API calls are: xkb_keysym_to_utf32 xkb_keysym_to_utf8 [daniels: Changed API to be more in line with keysym_get_name, added test, changed formatting to 4-space.]