51 using int_type = std::char_traits<char>::int_type;
52 using off_type = std::char_traits<char>::off_type;
53 using pos_type = std::char_traits<char>::pos_type;
102 static inline const std::size_t
InvalidPos{std::u32string::npos};
119 String(std::nullptr_t,
const std::locale& = {}) =
delete;
131 String(
char ansiChar,
const std::locale& locale = {});
159 String(
const char* ansiString,
const std::locale& locale = {});
171 String(
const std::string& ansiString,
const std::locale& locale = {});
216 template <
typename T>
230 template <
typename T>
248 template <
typename T>
266 operator std::string()
const;
281 operator std::wstring()
const;
298 [[nodiscard]] std::string
toAnsiString(
const std::locale& locale = {})
const;
422 void erase(std::size_t position, std::size_t count = 1);
448 [[nodiscard]] std::size_t
find(
const String& str, std::size_t start = 0)
const;
462 void replace(std::size_t position, std::size_t length,
const String& replaceWith);
504 [[nodiscard]]
const char32_t*
getData()
const;
561 std::u32string m_string;
650#include <SFML/System/String.inl>
ConstIterator begin() const
Return an iterator to the beginning of the string.
const char32_t * getData() const
Get a pointer to the C-style array of characters.
String(const std::string &ansiString, const std::locale &locale={})
Construct from an ANSI string and a locale.
bool operator>=(const String &left, const String &right)
Overload of operator>= to compare two UTF-32 strings.
std::string toAnsiString(const std::locale &locale={}) const
Convert the Unicode string to an ANSI string.
String()=default
Default constructor.
sf::U8String toUtf8() const
Convert the Unicode string to a UTF-8 string.
bool isEmpty() const
Check whether the string is empty or not.
String(std::u32string utf32String)
Construct from an UTF-32 string.
void clear()
Clear the string.
bool operator!=(const String &left, const String &right)
Overload of operator!= to compare two UTF-32 strings.
friend bool operator==(const String &left, const String &right)
String substring(std::size_t position, std::size_t length=InvalidPos) const
Return a part of the string.
String(char ansiChar, const std::locale &locale={})
Construct from a single ANSI character and a locale.
friend bool operator<(const String &left, const String &right)
String(const wchar_t *wideString)
Construct from null-terminated C-style wide string.
std::u32string toUtf32() const
Convert the Unicode string to a UTF-32 string.
String(const std::wstring &wideString)
Construct from a wide string.
char32_t operator[](std::size_t index) const
Overload of operator[] to access a character by its position.
String(const char *ansiString, const std::locale &locale={})
Construct from a null-terminated C-style ANSI string and a locale.
static String fromUtf16(T begin, T end)
Create a new sf::String from a UTF-16 encoded string.
void replace(const String &searchFor, const String &replaceWith)
Replace all occurrences of a substring with a replacement string.
Iterator begin()
Return an iterator to the beginning of the string.
std::wstring toWideString() const
Convert the Unicode string to a wide string.
std::size_t find(const String &str, std::size_t start=0) const
Find a sequence of one or more characters in the string.
static String fromUtf8(T begin, T end)
Create a new sf::String from a UTF-8 encoded string.
void erase(std::size_t position, std::size_t count=1)
Erase one or more characters from the string.
String(char32_t utf32Char)
Construct from single UTF-32 character.
static String fromUtf32(T begin, T end)
Create a new sf::String from a UTF-32 encoded string.
std::u16string toUtf16() const
Convert the Unicode string to a UTF-16 string.
static const std::size_t InvalidPos
Represents an invalid position in the string.
bool operator<=(const String &left, const String &right)
Overload of operator<= to compare two UTF-32 strings.
char32_t & operator[](std::size_t index)
Overload of operator[] to access a character by its position.
std::u32string::const_iterator ConstIterator
Read-only iterator type.
Iterator end()
Return an iterator to the end of the string.
bool operator>(const String &left, const String &right)
Overload of operator> to compare two UTF-32 strings.
String(const char32_t *utf32String)
Construct from a null-terminated C-style UTF-32 string.
void insert(std::size_t position, const String &str)
Insert one or more characters into the string.
void replace(std::size_t position, std::size_t length, const String &replaceWith)
Replace a substring with another string.
std::size_t getSize() const
Get the size of the string.
std::u32string::iterator Iterator
Iterator type.
String(wchar_t wideChar)
Construct from single wide character.
String operator+(const String &left, const String &right)
Overload of binary operator+ to concatenate two strings.
ConstIterator end() const
Return an iterator to the end of the string.
String(std::nullptr_t, const std::locale &={})=delete
Deleted std::nullptr_t constructor.
String & operator+=(const String &right)
Overload of operator+= to append an UTF-32 string.
std::basic_string< std::uint8_t, U8StringCharTraits > U8String
Portable replacement for std::basic_string<std::uint8_t>
Character traits for std::uint8_t
static bool eq_int_type(int_type i1, int_type i2) noexcept
static void assign(char_type &c1, char_type c2) noexcept
static char_type * copy(char_type *s1, const char_type *s2, std::size_t n)
static bool eq(char_type c1, char_type c2) noexcept
static int_type to_int_type(char_type c) noexcept
static int_type eof() noexcept
static char_type * move(char_type *s1, const char_type *s2, std::size_t n)
std::char_traits< char >::int_type int_type
static int compare(const char_type *s1, const char_type *s2, std::size_t n)
static std::size_t length(const char_type *s)
std::char_traits< char >::state_type state_type
static bool lt(char_type c1, char_type c2) noexcept
static int_type not_eof(int_type i) noexcept
std::char_traits< char >::pos_type pos_type
static const char_type * find(const char_type *s, std::size_t n, const char_type &c)
static char_type to_char_type(int_type i) noexcept
std::char_traits< char >::off_type off_type
static char_type * assign(char_type *s, std::size_t n, char_type c)