[libcamera-devel] [PATCH v5 2/7] libcamera: utils: Add method to remove non-ASCII characters
Jacopo Mondi
jacopo at jmondi.org
Mon Sep 28 13:32:34 CEST 2020
Hi Niklas,
On Fri, Sep 25, 2020 at 05:07:38PM +0200, Niklas Söderlund wrote:
> Add method that removes non-ASCII characters from a string.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
> Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> ---
> * Changes since v4
> - Update documentation.
>
> * Changes since v3
> - Fix spelling in comment.
> - Rename to toAscii()
> ---
> include/libcamera/internal/utils.h | 2 ++
> src/libcamera/utils.cpp | 17 +++++++++++++++++
> 2 files changed, 19 insertions(+)
>
> diff --git a/include/libcamera/internal/utils.h b/include/libcamera/internal/utils.h
> index a1b644b0345bdb48..ebb2c4038e196f05 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 a5232902191eec85..551658323700f00f 100644
> --- a/src/libcamera/utils.cpp
> +++ b/src/libcamera/utils.cpp
> @@ -334,6 +334,23 @@ details::StringSplitter split(const std::string &str, const std::string &delim)
> return details::StringSplitter(str, delim);
> }
>
> +/**
> + * \brief Remove any non-ASCII charachters from a string
s/charachters/characters
> + * \param[in] str The string to strip
> + *
> + * Remove all non-ASCII characters form a string.
s/form/from
> + *
> + * \return An ASCII string
\return A string equal to \a str stripped out of all non-ASCII characters
?
nits apart
Reviewed-by: Jacopo Mondi <jacopo at jmondi.org>
Thanks
j
> + */
> +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
> *
> --
> 2.28.0
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
More information about the libcamera-devel
mailing list