Skip to content

Commit

Permalink
Fix UTF8 handling for Color UI (MarlinFirmware#19708)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhapsodyv authored and thinkyhead committed Oct 16, 2020
1 parent 35c40bc commit 50410aa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions Marlin/src/lcd/tft/tft_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,17 @@ void TFT_String::add(uint8_t *string, int8_t index, uint8_t *itemString) {
eol();
}

void TFT_String::add(uint8_t *string) {
wchar_t wchar;
while (*string) {
string = get_utf8_value_cb(string, read_byte, &wchar);
if (wchar > 255) wchar |= 0x0080;
uint8_t ch = uint8_t(wchar & 0x00FF);
add_character(ch);
}
eol();
}

void TFT_String::add_character(uint8_t character) {
if (length < MAX_STRING_LENGTH) {
data[length] = character;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/tft/tft_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class TFT_String {

static void set();
static void add(uint8_t character) { add_character(character); eol(); }
static void add(uint8_t *string) { while (*string) { add_character(*string++); } eol(); }
static void add(uint8_t *string);
static void add(uint8_t *string, int8_t index, uint8_t *itemString = NULL);
static void set(uint8_t *string) { set(); add(string); };
static void set(uint8_t *string, int8_t index, const char *itemString = NULL) { set(); add(string, index, (uint8_t *)itemString); };
Expand Down

0 comments on commit 50410aa

Please sign in to comment.