Changeset 28a5ebd in mainline for uspace/srv/hid/input/layout/ar.c


Ignore:
Timestamp:
2020-06-18T15:39:50Z (4 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ce52c333
Parents:
4f663f3e
Message:

Use char32_t instead of wchat_t to represent UTF-32 strings

The intention of the native HelenOS string API has been always to
support Unicode in the UTF-8 and UTF-32 encodings as the sole character
representations and ignore the obsolete mess of older single-byte and
multibyte character encodings. Before C11, the wchar_t type has been
slightly misused for the purpose of the UTF-32 strings. The newer
char32_t type is obviously a much more suitable option. The standard
defines char32_t as uint_least32_t, thus we can take the liberty to fix
it to uint32_t.

To maintain compatilibity with the C Standard, the putwchar(wchar_t)
functions has been replaced by our custom putuchar(char32_t) functions
where appropriate.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/input/layout/ar.c

    r4f663f3e r28a5ebd  
    4444static errno_t ar_create(layout_t *);
    4545static void ar_destroy(layout_t *);
    46 static wchar_t ar_parse_ev(layout_t *, kbd_event_t *ev);
     46static char32_t ar_parse_ev(layout_t *, kbd_event_t *ev);
    4747
    4848layout_ops_t ar_ops = {
     
    5252};
    5353
    54 static wchar_t map_not_shifted[] = {
     54static char32_t map_not_shifted[] = {
    5555        [KC_BACKTICK] = L'ذ',
    5656
     
    110110};
    111111
    112 static wchar_t map_shifted[] = {
     112static char32_t map_shifted[] = {
    113113        [KC_BACKTICK] = L'ّ',
    114114
     
    168168};
    169169
    170 static wchar_t map_neutral[] = {
     170static char32_t map_neutral[] = {
    171171        [KC_BACKSPACE] = '\b',
    172172        [KC_TAB] = '\t',
     
    181181};
    182182
    183 static wchar_t map_numeric[] = {
     183static char32_t map_numeric[] = {
    184184        [KC_N7] = '7',
    185185        [KC_N8] = '8',
     
    196196};
    197197
    198 static wchar_t translate(unsigned int key, wchar_t *map, size_t map_length)
     198static char32_t translate(unsigned int key, char32_t *map, size_t map_length)
    199199{
    200200        if (key >= map_length)
     
    212212}
    213213
    214 static wchar_t ar_parse_ev(layout_t *state, kbd_event_t *ev)
    215 {
    216         wchar_t c;
     214static char32_t ar_parse_ev(layout_t *state, kbd_event_t *ev)
     215{
     216        char32_t c;
    217217
    218218        /* Produce no characters when Ctrl or Alt is pressed. */
     
    220220                return 0;
    221221
    222         c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof(wchar_t));
     222        c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof(char32_t));
    223223        if (c != 0)
    224224                return c;
    225225
    226226        if ((ev->mods & KM_SHIFT) != 0)
    227                 c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof(wchar_t));
     227                c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof(char32_t));
    228228        else
    229                 c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof(wchar_t));
     229                c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof(char32_t));
    230230
    231231        if (c != 0)
     
    233233
    234234        if ((ev->mods & KM_NUM_LOCK) != 0)
    235                 c = translate(ev->key, map_numeric, sizeof(map_numeric) / sizeof(wchar_t));
     235                c = translate(ev->key, map_numeric, sizeof(map_numeric) / sizeof(char32_t));
    236236        else
    237237                c = 0;
Note: See TracChangeset for help on using the changeset viewer.