mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-24 17:15:07 +03:00
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>
This commit is contained in:
parent
bdf1f0238a
commit
b33ec34331
2 changed files with 19 additions and 0 deletions
|
@ -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();
|
||||
|
||||
|
|
|
@ -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 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
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue