send_unicode.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Written by konstantin: vomindoraan
  2. #include "send_unicode.h"
  3. #include <ctype.h>
  4. #include <string.h>
  5. __attribute__((weak))
  6. void send_unicode_hex_string(const char* str) {
  7. if (!str) { return; } // Safety net
  8. while (*str) {
  9. // Find the next code point (token) in the string
  10. for (; *str == ' '; str++);
  11. size_t n = strcspn(str, " "); // Length of the current token
  12. char code_point[n+1];
  13. strncpy(code_point, str, n);
  14. code_point[n] = '\0'; // Make sure it's null-terminated
  15. // Normalize the code point: make all hex digits lowercase
  16. for (char *p = code_point; *p; p++) {
  17. *p = tolower((unsigned char)*p);
  18. }
  19. // Send the code point as a Unicode input string
  20. unicode_input_start();
  21. send_string(code_point);
  22. unicode_input_finish();
  23. str += n; // Move to the first ' ' (or '\0') after the current token
  24. }
  25. }
  26. // (ノಠ痊ಠ)ノ彡┻━┻
  27. // send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B");
  28. //Old code
  29. // (╯°□°)╯ ︵ ┻━┻
  30. #if 0
  31. register_code(KC_RSFT);
  32. tap(KC_9);
  33. unregister_code(KC_RSFT);
  34. process_unicode((0x256F | QK_UNICODE), record); // Arm
  35. process_unicode((0x00B0 | QK_UNICODE), record); // Eye
  36. process_unicode((0x25A1 | QK_UNICODE), record); // Mouth
  37. process_unicode((0x00B0 | QK_UNICODE), record); // Eye
  38. register_code(KC_RSFT);
  39. tap(KC_0);
  40. unregister_code(KC_RSFT);
  41. process_unicode((0x256F | QK_UNICODE), record); // Arm
  42. tap(KC_SPC);
  43. process_unicode((0x0361 | QK_UNICODE), record); // Flippy
  44. tap(KC_SPC);
  45. process_unicode((0x253B | QK_UNICODE), record); // Table
  46. process_unicode((0x2501 | QK_UNICODE), record); // Table
  47. process_unicode((0x253B | QK_UNICODE), record); // Table
  48. #endif
  49. // If you need a good converter: https://r12a.github.io/app-conversion/