diff options
| author | Joshua Diamond <josh@windowoffire.com> | 2022-09-18 11:51:04 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-18 11:51:04 -0400 |
| commit | a3a47a6556b42645cee43025fb0863e057d70a09 (patch) | |
| tree | e1b74b343da7dae7ef5df3a299b98ef3e57a1959 /quantum/unicode | |
| parent | f0940a6fe49fe302d4270234f303c01cb883b070 (diff) | |
Work around WinCompose issue for U+Axxx or U+Exxx (#18260)
* Work around WinCompose issue for U+Axxx or U+Exxx
* tzarc's more efficient version
Co-authored-by: Thomas <mail@tpreisner.de>
Diffstat (limited to 'quantum/unicode')
| -rw-r--r-- | quantum/unicode/unicode.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/quantum/unicode/unicode.c b/quantum/unicode/unicode.c index f9f429e7af..3f934c9277 100644 --- a/quantum/unicode/unicode.c +++ b/quantum/unicode/unicode.c | |||
| @@ -324,19 +324,26 @@ void register_hex(uint16_t hex) { | |||
| 324 | } | 324 | } |
| 325 | 325 | ||
| 326 | void register_hex32(uint32_t hex) { | 326 | void register_hex32(uint32_t hex) { |
| 327 | bool onzerostart = true; | 327 | bool first_digit = true; |
| 328 | bool needs_leading_zero = (unicode_config.input_mode == UC_WINC); | ||
| 328 | for (int i = 7; i >= 0; i--) { | 329 | for (int i = 7; i >= 0; i--) { |
| 329 | if (i <= 3) { | 330 | // Work out the digit we're going to transmit |
| 330 | onzerostart = false; | ||
| 331 | } | ||
| 332 | uint8_t digit = ((hex >> (i * 4)) & 0xF); | 331 | uint8_t digit = ((hex >> (i * 4)) & 0xF); |
| 333 | if (digit == 0) { | 332 | |
| 334 | if (!onzerostart) { | 333 | // If we're still searching for the first digit, and found one |
| 335 | send_nibble_wrapper(digit); | 334 | // that needs a leading zero sent out, send the zero. |
| 336 | } | 335 | if (first_digit && needs_leading_zero && digit > 9) { |
| 337 | } else { | 336 | send_nibble_wrapper(0); |
| 337 | } | ||
| 338 | |||
| 339 | // Always send digits (including zero) if we're down to the last | ||
| 340 | // two bytes of nibbles. | ||
| 341 | bool must_send = i < 4; | ||
| 342 | |||
| 343 | // If we've found a digit worth transmitting, do so. | ||
| 344 | if (digit != 0 || !first_digit || must_send) { | ||
| 338 | send_nibble_wrapper(digit); | 345 | send_nibble_wrapper(digit); |
| 339 | onzerostart = false; | 346 | first_digit = false; |
| 340 | } | 347 | } |
| 341 | } | 348 | } |
| 342 | } | 349 | } |
