|
Steppable 0.0.1
A CAS project written from scratch in C++
|
Utilities to operate strings. More...
Classes | |
| class | GraphemeIterator |
Functions | |
| bool | isZeroWidthCharacter (uint32_t codepoint) |
| Checks if a Unicode code point represents a zero-width character. | |
| bool | isEmojiBase (uint32_t cp) |
| bool | utf8Decode (const std::string &s, size_t &i, uint32_t &cp) |
| bool | isClusterExtender (uint32_t cp) |
| uint32_t | getCodepoint (const std::string &str, size_t &i) |
| Decodes a UTF-8 encoded string into a Unicode code point. | |
| size_t | getUnicodeDisplayWidth (const std::string &utf8Str) |
| Calculates the display width of a UTF-8 encoded string. | |
| std::string | makeWider (const std::string &orig) |
| Makes the given string wider by adding 2 spaces between each character. | |
| int | utf8ToUnicode (const std::string &utf8_code) |
| Converts a UTF-8 encoded string to a Unicode string. | |
| std::string | unicodeToUtf8 (int unicode) |
| Converts a Unicode character to UTF-8 encoding. | |
| template<typename CharT> | |
| auto | split (std::basic_string< CharT > s, const CharT separator) |
| Splits a string into substrings based on a separator. | |
| template<typename CharT> | |
| auto | split (std::basic_string_view< CharT > s, const CharT separator) |
| Splits a string view into substrings based on a separator. | |
| template<typename CharT> | |
| auto | rReplace (const std::basic_string< CharT > s, const CharT t, const CharT replacement='\0') |
| Replaces the trailing occurrences of a character in a string with another character. | |
| template<typename CharT> | |
| auto | lReplace (const std::basic_string< CharT > s, const CharT t, const CharT replacement='\0') |
| Replaces the leading occurrences of a character in a string with a replacement character. | |
| template<typename CharT> | |
| auto | bothEndsReplace (const std::basic_string< CharT > s, const CharT t, const CharT replacement='\0') |
| Replaces the leading and trailing occurrences of a character in a string with a replacement character. | |
| template<typename T> | |
| auto | join (const std::vector< T > &vector, const std::string &delimiter) |
| Joins a vector of elements into a single string using a delimiter. | |
| std::vector< std::string > | duplicates (const std::vector< std::string > &vector) |
| Gets the duplicates in a vector of strings. | |
| template<typename ValueType> | |
| std::string | vectorToString (const std::vector< ValueType > &vector) |
| template<concepts::Numeric T> | |
| T | toNumeric (const std::string &s) |
Utilities to operate strings.
| auto steppable::__internals::stringUtils::bothEndsReplace | ( | const std::basic_string< CharT > | s, |
| const CharT | t, | ||
| const CharT | replacement = '\0' ) |
Replaces the leading and trailing occurrences of a character in a string with a replacement character.
| CharT | The character type of the string. |
| [in] | s | The input string. |
| [in] | t | The character to be replaced. |
| [in] | replacement | The replacement character (default is '\0'). |
| std::vector< std::string > steppable::__internals::stringUtils::duplicates | ( | const std::vector< std::string > & | vector | ) |
Gets the duplicates in a vector of strings.
| [in] | vector | The vector of strings to check for duplicates. |
| uint32_t steppable::__internals::stringUtils::getCodepoint | ( | const std::string & | str, |
| size_t & | i ) |
Decodes a UTF-8 encoded string into a Unicode code point.
This function reads one UTF-8 encoded character from the string, starting at index i, and advances the index to the next character.
| str | The UTF-8 encoded string. |
| i | The current position in the string (updated after decoding). |
| size_t steppable::__internals::stringUtils::getUnicodeDisplayWidth | ( | const std::string & | utf8Str | ) |
Calculates the display width of a UTF-8 encoded string.
This function computes the total display width of a string, correctly handling wide, narrow, zero-width, and CJK characters. CJK characters are counted as one character.
| utf8Str | The UTF-8 encoded string. |
| bool steppable::__internals::stringUtils::isClusterExtender | ( | uint32_t | cp | ) |
| bool steppable::__internals::stringUtils::isEmojiBase | ( | uint32_t | cp | ) |
| bool steppable::__internals::stringUtils::isZeroWidthCharacter | ( | uint32_t | codepoint | ) |
Checks if a Unicode code point represents a zero-width character.
Zero-width characters do not consume display space (e.g., combining marks, zero-width spaces).
| codepoint | The Unicode code point to check. |
| auto steppable::__internals::stringUtils::join | ( | const std::vector< T > & | vector, |
| const std::string & | delimiter ) |
Joins a vector of elements into a single string using a delimiter.
| T | The type of the vector elements. |
| [in] | vector | The vector of strings to join. |
| [in] | delimiter | The delimiter to join the strings with. |
| auto steppable::__internals::stringUtils::lReplace | ( | const std::basic_string< CharT > | s, |
| const CharT | t, | ||
| const CharT | replacement = '\0' ) |
Replaces the leading occurrences of a character in a string with a replacement character.
| CharT | The character type of the string. |
| [in] | s | The input string. |
| [in] | t | The character to be replaced. |
| [in] | replacement | The replacement character (default is '\0'). |
| std::string steppable::__internals::stringUtils::makeWider | ( | const std::string & | orig | ) |
Makes the given string wider by adding 2 spaces between each character.
| [in] | orig | The original string. |
| auto steppable::__internals::stringUtils::rReplace | ( | const std::basic_string< CharT > | s, |
| const CharT | t, | ||
| const CharT | replacement = '\0' ) |
Replaces the trailing occurrences of a character in a string with another character.
This function takes a string s and replaces all trailing occurrences of the character t with the character replacement. If replacement is not provided, the trailing occurrences of t are simply removed.
| CharT | The character type of the string. |
| [in] | s | The input string. |
| [in] | t | The character to be replaced. |
| [in] | replacement | The character to replace t with. Default is '\0' (null character). |
| auto steppable::__internals::stringUtils::split | ( | std::basic_string< CharT > | s, |
| const CharT | separator ) |
Splits a string into substrings based on a separator.
| [in] | s | The string to be split. |
| [in] | separator | The separator to split the string by. |
| auto steppable::__internals::stringUtils::split | ( | std::basic_string_view< CharT > | s, |
| const CharT | separator ) |
Splits a string view into substrings based on a separator.
| [in] | s | The string view to be split. |
| [in] | separator | The separator to split the string view by. |
| T steppable::__internals::stringUtils::toNumeric | ( | const std::string & | s | ) |
| std::string steppable::__internals::stringUtils::unicodeToUtf8 | ( | int | unicode | ) |
Converts a Unicode character to UTF-8 encoding.
| [in] | unicode | The Unicode character to be converted. |
| bool steppable::__internals::stringUtils::utf8Decode | ( | const std::string & | s, |
| size_t & | i, | ||
| uint32_t & | cp ) |
| int steppable::__internals::stringUtils::utf8ToUnicode | ( | const std::string & | utf8_code | ) |
Converts a UTF-8 encoded string to a Unicode string.
| [in] | utf8_code | The UTF-8 encoded string to convert. |
| std::string steppable::__internals::stringUtils::vectorToString | ( | const std::vector< ValueType > & | vector | ) |