Comment on page
string
Libray to interact with strings.
A ASCII string with a prefixed size.
<SizeType>
: The type of the size field.
using SizedString<SizeType> = std::string::SizedStringBase;
A UTF-16 string with a prefixed size.
<SizeType>
: The type of the size field.
using SizedString16<SizeType> = std::string::SizedStringBase;
Base type for sized strings. Represents a string with its size preceeding it.
<SizeType>
: The type of the size field.<DataType>
: The type of the characters.
struct SizedStringBase<, > { ... } [[sealed, format, transform]];
Gets the length of a string.
string
: The string to get the length of.return
: The length of the string.
fn length(str string);
Gets the character at a given index.
string
: The string to get the character from.index
: The index of the character to get.return
: The character at the given index.
fn at(str string, u32 index);
Gets a substring of a string.
string
: The string to get the substring from.pos
: The position of the first character of the substring.count
: The number of characters to get.return
: The substring.
fn substr(str string, u32 pos, u32 count);
Converts a string to an integer.
string
: The string to convert.base
: The base of the number.return
: The integer.
fn parse_int(str string, u8 base);
Converts a string to a float.
string
: The string to convert.return
: The float.
fn parse_float(str string);
Converts any type to a string.
x
: The value to convert.return
: The string.
fn to_string(auto x);
Checks if a string starts with a given substring.
string
: The string to check.part
: The substring to check for.return
: True if the string starts with the substring, false otherwise.
fn starts_with(str string, str part);
Checks if a string ends with a given substring.
string
: The string to check.part
: The substring to check for.return
: True if the string ends with the substring, false otherwise.
fn ends_with(str string, str part);
Checks if a string contains a given substring.
string
: The string to check.part
: The substring to check for.return
: True if the string contains the substring, false otherwise.
fn contains(str string, str part);
Reverses a string.
string
: The string to reverse.return
: The reversed string.
fn reverse(str string);
Converts a string to upper case.
string
: The string to convert.return
: The converted string.
fn to_upper(str string);
Converts a string to lower case.
string
: The string to convert.return
: The converted string.
fn to_lower(str string);
Replaces all occurrences of a substring with another substring.
string
: The string to replace in.pattern
: The substring to replace.replace
: The substring to replace with.return
: The string with the replacements.
fn replace(str string, str pattern, str replace);
Last modified 6mo ago