namespace
#include <Containers/StringUtils.h>
StringUtils String utilities.
Functions
- auto commonPrefix(StringView a, StringView b) -> StringView
- Longest common prefix of two strings.
- void lowercaseInPlace(MutableStringView string)
- Convert ASCII characters in a string to lowercase, in place.
- auto lowercase(StringView string) -> String
- Convert ASCII characters in a string to lowercase.
- auto lowercase(String string) -> String
- void uppercaseInPlace(MutableStringView string)
- Convert ASCII characters in a string to uppercase, in place.
- auto uppercase(StringView string) -> String
- Convert ASCII characters in a string to uppercase, in place.
- auto uppercase(String string) -> String
- auto lowercaseUnicode(StringView string) -> String
- Convert characters in a UTF-8 string to lowercase with slower Unicode-aware method.
- auto uppercaseUnicode(StringView string) -> String
- Convert characters in a UTF-8 string to uppercase with slower Unicode-aware method.
- auto equalsIgnoreCase(StringView string1, StringView string2) -> bool
- Determine whether two strings have the same value, ignoring case (ASCII characters only)
- auto replaceFirst(StringView string, StringView search, StringView replace) -> String
- Replace first occurrence in a string.
- auto replaceAll(StringView string, StringView search, StringView replace) -> String
- Replace all occurrences in a string.
- auto replaceAll(String string, char search, char replace) -> String
- Replace all occurrences of a character in a string with another character.
- void replaceAllInPlace(MutableStringView string, char search, char replace)
- Replace all occurrences of a character in a string with another character in-place.
Function documentation
StringView Death:: Containers:: StringUtils:: commonPrefix(StringView a,
StringView b)
Longest common prefix of two strings.
The returned view is a prefix of a
.
void Death:: Containers:: StringUtils:: lowercaseInPlace(MutableStringView string)
Convert ASCII characters in a string to lowercase, in place.
Replaces any character from ABCDEFGHIJKLMNOPQRSTUVWXYZ
with a corresponding character from abcdefghijklmnopqrstuvwxyz
. Deliberately supports only ASCII as Unicode-aware case conversion is a much more complex topic.
String Death:: Containers:: StringUtils:: lowercase(StringView string)
Convert ASCII characters in a string to lowercase.
Allocates a copy and replaces any character from ABCDEFGHIJKLMNOPQRSTUVWXYZ
with a corresponding character from abcdefghijklmnopqrstuvwxyz
. Deliberately supports only ASCII as Unicode-aware case conversion is a much more complex topic.
String Death:: Containers:: StringUtils:: lowercase(String string)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Compared to lowercase(StringView) is able to perform the operation in-place if string
is owned, transferring the data ownership to the returned instance. Makes a owned copy first if not.
void Death:: Containers:: StringUtils:: uppercaseInPlace(MutableStringView string)
Convert ASCII characters in a string to uppercase, in place.
Replaces any character from abcdefghijklmnopqrstuvwxyz
with a corresponding character from ABCDEFGHIJKLMNOPQRSTUVWXYZ
. Deliberately supports only ASCII as Unicode-aware case conversion is a much more complex topic.
String Death:: Containers:: StringUtils:: uppercase(StringView string)
Convert ASCII characters in a string to uppercase, in place.
Allocates a copy and replaces any character from abcdefghijklmnopqrstuvwxyz
with a corresponding character from ABCDEFGHIJKLMNOPQRSTUVWXYZ
. Deliberately supports only ASCII as Unicode-aware case conversion is a much more complex topic.
String Death:: Containers:: StringUtils:: uppercase(String string)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Compared to uppercase(StringView) is able to perform the operation in-place if string
is owned, transferring the data ownership to the returned instance. Makes a owned copy first if not.
String Death:: Containers:: StringUtils:: lowercaseUnicode(StringView string)
Convert characters in a UTF-8 string to lowercase with slower Unicode-aware method.
Allocates a copy and replaces most of the Latin, Greek, Cyrillic, Armenian, Georgian, Cherokee, Glagolitic, Coptic, Deseret, Osage, Old Hungarian, Warang Citi, Medefaidrin and Adlam characters. Doesn't support locale-specific replacements.
String Death:: Containers:: StringUtils:: uppercaseUnicode(StringView string)
Convert characters in a UTF-8 string to uppercase with slower Unicode-aware method.
Allocates a copy and replaces most of the Latin, Greek, Cyrillic, Armenian, Georgian, Cherokee, Glagolitic, Coptic, Deseret, Osage, Old Hungarian, Warang Citi, Medefaidrin and Adlam characters. Doesn't support locale-specific replacements.
String Death:: Containers:: StringUtils:: replaceFirst(StringView string,
StringView search,
StringView replace)
Replace first occurrence in a string.
Returns string
unmodified if it doesn't contain search
. Having empty search
causes replace
to be prepended to string
.
String Death:: Containers:: StringUtils:: replaceAll(StringView string,
StringView search,
StringView replace)
Replace all occurrences in a string.
Returns string
unmodified if it doesn't contain search
. Expects that search
is not empty, as that would cause an infinite loop. For substituting a single character with another the replaceAll(String, char, char) variant is more optimal.
String Death:: Containers:: StringUtils:: replaceAll(String string,
char search,
char replace)
Replace all occurrences of a character in a string with another character.
The string
is passed through unmodified if it doesn't contain search
. Otherwise the operation is performed in-place if string
is owned, transferring the data ownership to the returned instance. An owned copy is made if not. See also replaceAllInPlace() for a variant that operates on string views.