Text utilities.
Namespaces | |
namespace | utf8 |
UTF8 text utilities. | |
Enumerations | |
enum class | SplitFlags { kNone = 0 , kCompressAdjacentSeparators = 1 << 0 } |
Functions | |
std::string | Trim (const std::string &str) |
Return trimmed copy of string. | |
std::string | Trim (std::string &&str) |
Trim string in-place. | |
std::vector< std::string > | Split (std::string_view str, std::string_view separators, SplitFlags split_flags=SplitFlags::kCompressAdjacentSeparators) |
std::vector< std::string_view > | SplitIntoStringViewVector (std::string_view str, std::string_view separators) |
std::string | Join (const std::vector< std::string > &strs, std::string_view sep) |
Join string. | |
std::string | Format (double value, int ndigits) |
Return number formatted. | |
constexpr bool | StartsWith (std::string_view hay, std::string_view needle) noexcept |
Return true if hay starts with needle , false otherwise. | |
constexpr bool | EndsWith (std::string_view hay, std::string_view needle) noexcept |
Return true if hay ends with needle , false otherwise. | |
bool | ICaseStartsWith (std::string_view hay, std::string_view needle) noexcept |
Case insensitive (ASCII only) variant of StartsWith() | |
bool | ICaseEndsWith (std::string_view hay, std::string_view needle) noexcept |
Case insensitive (ASCII only) variant of EndsWith() | |
std::string | RemoveQuotes (std::string_view str) |
bool | IsAscii (char ch) noexcept |
Checks whether the character is an ASCII character. | |
bool | IsAsciiSpace (char ch) noexcept |
Checks whether the character is a whitespace character in C locale. | |
bool | IsAscii (std::string_view text) noexcept |
Checks if text contains only ASCII characters. | |
bool | IsUtf8 (std::string_view text) noexcept |
Checks if text is in utf-8 encoding. | |
bool | IsPrintable (std::string_view text, bool ascii_only=true) noexcept |
bool | IsCString (std::string_view text) noexcept |
Checks if there are no embedded null ('\0') characters in text. | |
std::string | CamelCaseToSnake (std::string_view camel) |
convert CamelCase to snake_case(underscore) | |
std::string | Format (double value, const std::string &locale, int ndigits=0, bool is_fixed=true) |
Return number formatted with specified locale. | |
std::string | ToLower (std::string_view str, const std::string &locale=kEnLocale) |
Transform letters to lower case. | |
std::string | ToUpper (std::string_view str, const std::string &locale=kEnLocale) |
Transform letters to upper case. | |
std::string | Capitalize (std::string_view str, const std::string &locale) |
Capitalizes the first letter of the str. | |
const std::locale & | GetLocale (const std::string &name) |
Returns a locale with the specified name. | |
Variables | |
const std::string | kEnLocale {"en_US.UTF-8"} |
|
strong |
Definition at line 22 of file text_light.hpp.
|
constexprnoexcept |
Return true if hay
ends with needle
, false otherwise.
Definition at line 55 of file text_light.hpp.
Checks text on matching to the following conditions:
std::string utils::text::RemoveQuotes | ( | std::string_view | str | ) |
Removes double quotes from front and back of string.
Examples:
std::vector< std::string > utils::text::Split | ( | std::string_view | str, |
std::string_view | separators, | ||
SplitFlags | split_flags = SplitFlags::kCompressAdjacentSeparators ) |
Split string by separators
std::vector< std::string_view > utils::text::SplitIntoStringViewVector | ( | std::string_view | str, |
std::string_view | separators ) |
Split string by separators and return a non-owning container of chunks.
str
should outlive the result of the function
|
constexprnoexcept |
Return true if hay
starts with needle
, false otherwise.
Definition at line 50 of file text_light.hpp.