Added support for filtering UTF-8 strings using UTF8-CPP

This commit is contained in:
Leon Styhre 2024-01-03 17:29:22 +01:00
parent b296180af3
commit d934cfb48f
3 changed files with 11 additions and 0 deletions

View file

@ -449,6 +449,7 @@ set(COMMON_INCLUDE_DIRS ${CURL_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/external/lunasvg/include
${CMAKE_CURRENT_SOURCE_DIR}/external/rapidjson/include
${CMAKE_CURRENT_SOURCE_DIR}/external/rlottie/inc
${CMAKE_CURRENT_SOURCE_DIR}/external/utfcpp/source
${CMAKE_CURRENT_SOURCE_DIR}/es-core/src
${CMAKE_CURRENT_SOURCE_DIR}/es-pdf-converter/src)

View file

@ -569,6 +569,13 @@ namespace Utils
return line;
}
std::string filterUtf8(const std::string& stringArg)
{
std::string tempString;
utf8::replace_invalid(stringArg.begin(), stringArg.end(), back_inserter(tempString));
return tempString;
}
std::string trim(const std::string& stringArg)
{
std::string trimString = stringArg;

View file

@ -14,6 +14,8 @@
#include <string>
#include <vector>
#include "utf8.h"
namespace Utils
{
namespace String
@ -28,6 +30,7 @@ namespace Utils
std::string toLower(const std::string& stringArg);
std::string toUpper(const std::string& stringArg);
std::string toCapitalized(const std::string& stringArg);
std::string filterUtf8(const std::string& stringArg);
std::string trim(const std::string& stringArg);
std::string replace(const std::string& stringArg,
const std::string& from,