From ef151e243b0895ecc426120d85dcdb5ac7677383 Mon Sep 17 00:00:00 2001 From: heurist1 Date: Tue, 28 Feb 2023 19:04:03 +0000 Subject: [PATCH] Imprment string trimr to remove spaces at the end of aircraft name. (cherry picked from commit 70fd4039938cdd45f03d541e0aff1238de85fb3e) --- firmware/application/string_format.cpp | 6 ++++++ firmware/application/string_format.hpp | 3 +++ 2 files changed, 9 insertions(+) diff --git a/firmware/application/string_format.cpp b/firmware/application/string_format.cpp index 3529a2d7b..0af9dc3d2 100644 --- a/firmware/application/string_format.cpp +++ b/firmware/application/string_format.cpp @@ -255,3 +255,9 @@ double get_decimals(double num, int16_t mult, bool round) { if (num > .5) intnum++; //Round up return intnum; } + +std::string trimr(std::string str) +{ + size_t last = str.find_last_not_of(' '); + return (last!=std::string::npos) ? str.substr(0, last+1) : ""; // Remove the trailing spaces +} \ No newline at end of file diff --git a/firmware/application/string_format.hpp b/firmware/application/string_format.hpp index db32072e2..848a53e3e 100644 --- a/firmware/application/string_format.hpp +++ b/firmware/application/string_format.hpp @@ -58,4 +58,7 @@ std::string to_string_FAT_timestamp(const FATTimestamp& timestamp); std::string unit_auto_scale(double n, const uint32_t base_nano, uint32_t precision); double get_decimals(double num, int16_t mult, bool round = false); //euquiq added + +std::string trimr(std::string str); // Remove trailing spaces + #endif/*__STRING_FORMAT_H__*/