Implement UTF8 switch #1108

This commit is contained in:
Bodmer 2021-04-23 16:51:18 +01:00
parent 018c884312
commit 233b98aa05
4 changed files with 10 additions and 11 deletions

View File

@ -3730,14 +3730,14 @@ uint8_t TFT_eSPI::getAttribute(uint8_t attr_id) {
** Function name: decodeUTF8 ** Function name: decodeUTF8
** Description: Serial UTF-8 decoder with fall-back to extended ASCII ** Description: Serial UTF-8 decoder with fall-back to extended ASCII
*************************************************************************************x*/ *************************************************************************************x*/
#define DECODE_UTF8 // Test only, comment out to stop decoding
uint16_t TFT_eSPI::decodeUTF8(uint8_t c) uint16_t TFT_eSPI::decodeUTF8(uint8_t c)
{ {
#ifdef DECODE_UTF8 if (!_utf8) return c;
// 7 bit Unicode Code Point // 7 bit Unicode Code Point
if ((c & 0x80) == 0x00) { if ((c & 0x80) == 0x00) {
decoderState = 0; decoderState = 0;
return (uint16_t)c; return c;
} }
if (decoderState == 0) { if (decoderState == 0) {
@ -3754,7 +3754,7 @@ uint16_t TFT_eSPI::decodeUTF8(uint8_t c)
return 0; return 0;
} }
// 21 bit Unicode Code Point not supported so fall-back to extended ASCII // 21 bit Unicode Code Point not supported so fall-back to extended ASCII
// if ((c & 0xF8) == 0xF0) return (uint16_t)c; // if ((c & 0xF8) == 0xF0) return c;
} }
else { else {
if (decoderState == 2) { if (decoderState == 2) {
@ -3770,9 +3770,8 @@ uint16_t TFT_eSPI::decodeUTF8(uint8_t c)
} }
decoderState = 0; decoderState = 0;
#endif
return (uint16_t)c; // fall-back to extended ASCII return c; // fall-back to extended ASCII
} }
@ -3785,7 +3784,8 @@ uint16_t TFT_eSPI::decodeUTF8(uint8_t *buf, uint16_t *index, uint16_t remaining)
uint16_t c = buf[(*index)++]; uint16_t c = buf[(*index)++];
//Serial.print("Byte from string = 0x"); Serial.println(c, HEX); //Serial.print("Byte from string = 0x"); Serial.println(c, HEX);
#ifdef DECODE_UTF8 if (!_utf8) return c;
// 7 bit Unicode // 7 bit Unicode
if ((c & 0x80) == 0x00) return c; if ((c & 0x80) == 0x00) return c;
@ -3801,7 +3801,6 @@ uint16_t TFT_eSPI::decodeUTF8(uint8_t *buf, uint16_t *index, uint16_t remaining)
// 21 bit Unicode not supported so fall-back to extended ASCII // 21 bit Unicode not supported so fall-back to extended ASCII
// if ((c & 0xF8) == 0xF0) return c; // if ((c & 0xF8) == 0xF0) return c;
#endif
return c; // fall-back to extended ASCII return c; // fall-back to extended ASCII
} }

View File

@ -16,7 +16,7 @@
#ifndef _TFT_eSPIH_ #ifndef _TFT_eSPIH_
#define _TFT_eSPIH_ #define _TFT_eSPIH_
#define TFT_ESPI_VERSION "2.3.65" #define TFT_ESPI_VERSION "2.3.66"
// Bit level feature flags // Bit level feature flags
// Bit 0 set: viewport capability // Bit 0 set: viewport capability

View File

@ -1,6 +1,6 @@
{ {
"name": "TFT_eSPI", "name": "TFT_eSPI",
"version": "2.3.65", "version": "2.3.66",
"keywords": "Arduino, tft, ePaper, display, Pico, RP2040, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9481, ILI9486, ILI9488, ST7789, RM68140, SSD1963, ILI9225, HX8357D", "keywords": "Arduino, tft, ePaper, display, Pico, RP2040, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9481, ILI9486, ILI9488, ST7789, RM68140, SSD1963, ILI9225, HX8357D",
"description": "A TFT and ePaper SPI graphics library with optimisation for Raspberry Pi Pico, ESP8266, ESP32 and STM32", "description": "A TFT and ePaper SPI graphics library with optimisation for Raspberry Pi Pico, ESP8266, ESP32 and STM32",
"repository": "repository":

View File

@ -1,5 +1,5 @@
name=TFT_eSPI name=TFT_eSPI
version=2.3.65 version=2.3.66
author=Bodmer author=Bodmer
maintainer=Bodmer maintainer=Bodmer
sentence=TFT graphics library for Arduino processors with performance optimisation for RP2040, STM32, ESP8266 and ESP32 sentence=TFT graphics library for Arduino processors with performance optimisation for RP2040, STM32, ESP8266 and ESP32