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/us_dvorak.c

    r4f663f3e r28a5ebd  
    4343static errno_t us_dvorak_create(layout_t *);
    4444static void us_dvorak_destroy(layout_t *);
    45 static wchar_t us_dvorak_parse_ev(layout_t *, kbd_event_t *ev);
     45static char32_t us_dvorak_parse_ev(layout_t *, kbd_event_t *ev);
    4646
    4747layout_ops_t us_dvorak_ops = {
     
    5151};
    5252
    53 static wchar_t map_lcase[] = {
     53static char32_t map_lcase[] = {
    5454        [KC_R] = 'p',
    5555        [KC_T] = 'y',
     
    8484};
    8585
    86 static wchar_t map_ucase[] = {
     86static char32_t map_ucase[] = {
    8787        [KC_R] = 'P',
    8888        [KC_T] = 'Y',
     
    117117};
    118118
    119 static wchar_t map_not_shifted[] = {
     119static char32_t map_not_shifted[] = {
    120120        [KC_BACKTICK] = '`',
    121121
     
    147147};
    148148
    149 static wchar_t map_shifted[] = {
     149static char32_t map_shifted[] = {
    150150        [KC_BACKTICK] = '~',
    151151
     
    177177};
    178178
    179 static wchar_t map_neutral[] = {
     179static char32_t map_neutral[] = {
    180180        [KC_BACKSPACE] = '\b',
    181181        [KC_TAB] = '\t',
     
    190190};
    191191
    192 static wchar_t map_numeric[] = {
     192static char32_t map_numeric[] = {
    193193        [KC_N7] = '7',
    194194        [KC_N8] = '8',
     
    205205};
    206206
    207 static wchar_t translate(unsigned int key, wchar_t *map, size_t map_length)
     207static char32_t translate(unsigned int key, char32_t *map, size_t map_length)
    208208{
    209209        if (key >= map_length)
     
    221221}
    222222
    223 static wchar_t us_dvorak_parse_ev(layout_t *state, kbd_event_t *ev)
    224 {
    225         wchar_t c;
     223static char32_t us_dvorak_parse_ev(layout_t *state, kbd_event_t *ev)
     224{
     225        char32_t c;
    226226
    227227        /* Produce no characters when Ctrl or Alt is pressed. */
     
    229229                return 0;
    230230
    231         c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof(wchar_t));
     231        c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof(char32_t));
    232232        if (c != 0)
    233233                return c;
    234234
    235235        if (((ev->mods & KM_SHIFT) != 0) ^ ((ev->mods & KM_CAPS_LOCK) != 0))
    236                 c = translate(ev->key, map_ucase, sizeof(map_ucase) / sizeof(wchar_t));
     236                c = translate(ev->key, map_ucase, sizeof(map_ucase) / sizeof(char32_t));
    237237        else
    238                 c = translate(ev->key, map_lcase, sizeof(map_lcase) / sizeof(wchar_t));
     238                c = translate(ev->key, map_lcase, sizeof(map_lcase) / sizeof(char32_t));
    239239
    240240        if (c != 0)
     
    242242
    243243        if ((ev->mods & KM_SHIFT) != 0)
    244                 c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof(wchar_t));
     244                c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof(char32_t));
    245245        else
    246                 c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof(wchar_t));
     246                c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof(char32_t));
    247247
    248248        if (c != 0)
     
    250250
    251251        if ((ev->mods & KM_NUM_LOCK) != 0)
    252                 c = translate(ev->key, map_numeric, sizeof(map_numeric) / sizeof(wchar_t));
     252                c = translate(ev->key, map_numeric, sizeof(map_numeric) / sizeof(char32_t));
    253253        else
    254254                c = 0;
Note: See TracChangeset for help on using the changeset viewer.