diff --git a/src/lang/string_view_utf8.hpp b/src/lang/string_view_utf8.hpp index 35949eb846..7cf49791e9 100644 --- a/src/lang/string_view_utf8.hpp +++ b/src/lang/string_view_utf8.hpp @@ -230,32 +230,6 @@ class string_view_utf8 { return dst - dst_start; } - /// Copy the string byte-by-byte into some RAM buffer for later processing, without multibyte cutting check - /// typically used to obtain a translated version of a format string for s(n)printf - /// @param dst target buffer to copy the bytes to - /// @param buffer_size size of dst in bytes - /// @returns number of bytes (not utf8 characters) copied not counting the terminating '\0' - /// Using sprintf to format some string is possible with translations, but it requires one more step than usually - - /// one must first fetch the translated format string into a RAM buffer and then feed the format string into standard sprintf - size_t copyBytesToRAM(char *dst, size_t buffer_size) { - if (buffer_size == 0) { - return 0; - } - char *dst_start = dst; - for (size_t i = 0; i < buffer_size; ++i) { - *dst = getbyte(attrs); - if (*dst == 0) { - return dst - dst_start; - } - ++dst; - } - - // Beware - no multibyte character check! - // dst pointer is decremented to point at the last character of the buffer - *(--dst) = 0; // safety termination in case of reaching the end of the buffer - return dst - dst_start; - } - /// Construct string_view_utf8 to provide data from CPU FLASH static string_view_utf8 MakeCPUFLASH(const uint8_t *utf8raw) { string_view_utf8 s; diff --git a/tests/unit/lang/string_view_utf8/tests.cpp b/tests/unit/lang/string_view_utf8/tests.cpp index dcda8cb4a4..80ff9bed48 100644 --- a/tests/unit/lang/string_view_utf8/tests.cpp +++ b/tests/unit/lang/string_view_utf8/tests.cpp @@ -229,7 +229,4 @@ TEST_CASE("string_view_utf8::CopyToRAM dst buffer too small + multibyte chars", size_t copied_bytes = orig.copyToRAM(dst, sizeof(dst)); REQUIRE_THAT(dst, Equals(ref)); REQUIRE(copied_bytes == sizeof(ref) - 1); // -1 because we don't count copying null at the end - - copied_bytes = orig.copyBytesToRAM(dst, sizeof(dst)); - REQUIRE(copied_bytes == sizeof(dst) - 1); }