diff options
author | Niklas Söderlund <niklas.soderlund@ragnatech.se> | 2020-08-10 17:32:01 +0200 |
---|---|---|
committer | Niklas Söderlund <niklas.soderlund@ragnatech.se> | 2020-10-02 15:04:41 +0200 |
commit | b33ec3433194b50f2f6b8e4038c321b6f3293798 (patch) | |
tree | ba9e150ebb8294599cbd68737310cc18a2fbd82d | |
parent | bdf1f0238af24db773a78981aa29404c45802792 (diff) |
libcamera: utils: Add method to remove non-ASCII characters
Add method that removes non-ASCII characters from a string.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Umang Jain <email@uajain.com>
-rw-r--r-- | include/libcamera/internal/utils.h | 2 | ||||
-rw-r--r-- | src/libcamera/utils.cpp | 17 |
2 files changed, 19 insertions, 0 deletions
diff --git a/include/libcamera/internal/utils.h b/include/libcamera/internal/utils.h index a1b644b0..ebb2c403 100644 --- a/include/libcamera/internal/utils.h +++ b/include/libcamera/internal/utils.h @@ -190,6 +190,8 @@ private: details::StringSplitter split(const std::string &str, const std::string &delim); +std::string toAscii(const std::string &str); + std::string libcameraBuildPath(); std::string libcameraSourcePath(); diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp index a5232902..da85c9c2 100644 --- a/src/libcamera/utils.cpp +++ b/src/libcamera/utils.cpp @@ -335,6 +335,23 @@ details::StringSplitter split(const std::string &str, const std::string &delim) } /** + * \brief Remove any non-ASCII characters from a string + * \param[in] str The string to strip + * + * Remove all non-ASCII characters from a string. + * + * \return A string equal to \a str stripped out of all non-ASCII characters + */ +std::string toAscii(const std::string &str) +{ + std::string ret; + for (const char &c : str) + if (!(c & 0x80)) + ret += c; + return ret; +} + +/** * \brief Check if libcamera is installed or not * * Utilise the build_rpath dynamic tag which is stripped out by meson at |