From d70a9392affb9ace3c3c32af9acc8129ab6976b7 Mon Sep 17 00:00:00 2001 From: ChangYanChu Date: Sat, 8 Feb 2025 20:03:44 +0800 Subject: [PATCH 1/2] improve UTF-8 string handling in JSONValue (#6011) ```text feat(json): improve UTF-8 string handling in JSONValue - Add proper UTF-8 multi-byte character sequence handling - Add boundary checks for UTF-8 sequences - Keep original code structure and flow - Add detailed comments for UTF-8 processing logic This change improves the robustness of JSON string handling while maintaining compatibility with existing code. --- src/serialization/JSONValue.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/serialization/JSONValue.cpp b/src/serialization/JSONValue.cpp index 64dc10abe..20cd90373 100644 --- a/src/serialization/JSONValue.cpp +++ b/src/serialization/JSONValue.cpp @@ -850,18 +850,26 @@ std::string JSONValue::StringifyString(const std::string &str) str_out += "\\r"; } else if (chr == '\t') { str_out += "\\t"; - } else if (chr < ' ' || chr > 126) { - str_out += "\\u"; - for (int i = 0; i < 4; i++) { - int value = (chr >> 12) & 0xf; - if (value >= 0 && value <= 9) - str_out += (char)('0' + value); - else if (value >= 10 && value <= 15) - str_out += (char)('A' + (value - 10)); - chr <<= 4; - } + } else if (chr < 0x20 || chr == 0x7F) { + char buf[7]; + snprintf(buf, sizeof(buf), "\\u%04x", chr); + str_out += buf; + } else if (chr < 0x80) { + str_out += chr; } else { str_out += chr; + size_t remain = str.end() - iter - 1; + if ((chr & 0xE0) == 0xC0 && remain >= 1) { + ++iter; + str_out += *iter; + } else if ((chr & 0xF0) == 0xE0 && remain >= 2) { + str_out += *(++iter); + str_out += *(++iter); + } else if ((chr & 0xF8) == 0xF0 && remain >= 3) { + str_out += *(++iter); + str_out += *(++iter); + str_out += *(++iter); + } } ++iter; From 26a0612e37a137fc0db9ebd9a1abbeecf7f66443 Mon Sep 17 00:00:00 2001 From: Manuel <71137295+mverch67@users.noreply.github.com> Date: Sat, 8 Feb 2025 18:06:03 +0100 Subject: [PATCH 2/2] fixed Indicator touch issue (causing IO expander issues), added more RAM (#6013) --- lib/device-ui | 2 +- variants/seeed-sensecap-indicator/platformio.ini | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/device-ui b/lib/device-ui index e500683c7..7d2ff838a 160000 --- a/lib/device-ui +++ b/lib/device-ui @@ -1 +1 @@ -Subproject commit e500683c7b9d070f14746425680d999140d45361 +Subproject commit 7d2ff838aa8d5ad2f3dc9b0210dcaedb87d7f84d diff --git a/variants/seeed-sensecap-indicator/platformio.ini b/variants/seeed-sensecap-indicator/platformio.ini index aa4da58bd..6b6abae6c 100644 --- a/variants/seeed-sensecap-indicator/platformio.ini +++ b/variants/seeed-sensecap-indicator/platformio.ini @@ -52,7 +52,7 @@ build_flags = -D HAS_TFT=1 -D DISPLAY_SET_RESOLUTION -D USE_I2S_BUZZER - -D RAM_SIZE=1024 + -D RAM_SIZE=3072 -D LV_LVGL_H_INCLUDE_SIMPLE -D LV_CONF_INCLUDE_SIMPLE -D LV_COMP_CONF_INCLUDE_SIMPLE @@ -63,7 +63,7 @@ build_flags = -D LV_USE_LOG=0 -D USE_LOG_DEBUG -D LOG_DEBUG_INC=\"DebugConfiguration.h\" -; -D CUSTOM_TOUCH_DRIVER + -D CUSTOM_TOUCH_DRIVER ; -D CALIBRATE_TOUCH=0 -D LGFX_DRIVER=LGFX_INDICATOR -D GFX_DRIVER_INC=\"graphics/LGFX/LGFX_INDICATOR.h\"