Browse Source

Fix UTF8 handling for Color UI (#19708)

Victor Oliveira 3 years ago
parent
commit
50410aaeaa
2 changed files with 12 additions and 1 deletions
  1. 11
    0
      Marlin/src/lcd/tft/tft_string.cpp
  2. 1
    1
      Marlin/src/lcd/tft/tft_string.h

+ 11
- 0
Marlin/src/lcd/tft/tft_string.cpp View File

@@ -116,6 +116,17 @@ void TFT_String::add(uint8_t *string, int8_t index, uint8_t *itemString) {
116 116
   eol();
117 117
 }
118 118
 
119
+void TFT_String::add(uint8_t *string) {
120
+  wchar_t wchar;
121
+  while (*string) {
122
+    string = get_utf8_value_cb(string, read_byte, &wchar);
123
+    if (wchar > 255) wchar |= 0x0080;
124
+    uint8_t ch = uint8_t(wchar & 0x00FF);
125
+    add_character(ch);
126
+  }
127
+  eol();
128
+}
129
+
119 130
 void TFT_String::add_character(uint8_t character) {
120 131
   if (length < MAX_STRING_LENGTH) {
121 132
     data[length] = character;

+ 1
- 1
Marlin/src/lcd/tft/tft_string.h View File

@@ -85,7 +85,7 @@ class TFT_String {
85 85
 
86 86
     static void set();
87 87
     static void add(uint8_t character) { add_character(character); eol(); }
88
-    static void add(uint8_t *string) { while (*string) { add_character(*string++); } eol(); }
88
+    static void add(uint8_t *string);
89 89
     static void add(uint8_t *string, int8_t index, uint8_t *itemString = NULL);
90 90
     static void set(uint8_t *string) { set(); add(string); };
91 91
     static void set(uint8_t *string, int8_t index, const char *itemString = NULL) { set(); add(string, index, (uint8_t *)itemString); };

Loading…
Cancel
Save