Colobot
|
Some useful string operations. More...
#include <cstddef>
#include <string>
#include <sstream>
Go to the source code of this file.
Functions | |
template<class T > | |
std::string | StrUtils::ToString (T value, bool *ok=nullptr) |
Converts a value to string. More... | |
template<class T > | |
T | StrUtils::FromString (const std::string &str, bool *ok=nullptr) |
Converts a value to string. More... | |
unsigned int | StrUtils::HexStringToInt (const std::string &str) |
Converts string of hex characters to int. More... | |
std::string | StrUtils::Format (const char *fmt,...) |
Replacement for sprintf() More... | |
std::string | StrUtils::Replace (const std::string &str, const std::string &oldStr, const std::string &newStr) |
Returns a string with every occurence of oldStr in str replaced to newStr. More... | |
std::string | StrUtils::UnicodeCharToUtf8 (unsigned int ch) |
Converts a wide Unicode char to a single UTF-8 encoded char. More... | |
std::string | StrUtils::UnicodeStringToUtf8 (const std::wstring &str) |
Converts a wide Unicode string to a UTF-8 encoded string. More... | |
unsigned int | StrUtils::Utf8CharToUnicode (const std::string &ch) |
Converts a UTF-8 encoded single character to wide Unicode char. More... | |
std::wstring | StrUtils::Utf8StringToUnicode (const std::string &str) |
Converts a UTF-8 encoded string to wide Unicode string. More... | |
int | StrUtils::Utf8CharSizeAt (const std::string &str, unsigned int pos) |
Returns the size in bytes of UTF-8 character at given pos in a UTF-8 str. More... | |
std::size_t | StrUtils::Utf8StringLength (const std::string &str) |
Returns the length in characters of UTF-8 string str. More... | |
Some useful string operations.
std::string StrUtils::ToString | ( | T | value, |
bool * | ok = nullptr |
||
) |
Converts a value to string.
If given, ok is set to true/false on success/failure. Warning: To avoid unnecessary problems, always give full template qualifier e.g. ToString<int>
T StrUtils::FromString | ( | const std::string & | str, |
bool * | ok = nullptr |
||
) |
Converts a value to string.
If given, ok is set to true/false on success/failure. Warning: To avoid unnecessary problems, always give full template qualifier e.g. FromString<int>
unsigned int StrUtils::HexStringToInt | ( | const std::string & | str | ) |
Converts string of hex characters to int.
std::string StrUtils::Format | ( | const char * | fmt, |
... | |||
) |
Replacement for sprintf()
std::string StrUtils::Replace | ( | const std::string & | str, |
const std::string & | oldStr, | ||
const std::string & | newStr | ||
) |
Returns a string with every occurence of oldStr in str replaced to newStr.
std::string StrUtils::UnicodeCharToUtf8 | ( | unsigned int | ch | ) |
Converts a wide Unicode char to a single UTF-8 encoded char.
std::string StrUtils::UnicodeStringToUtf8 | ( | const std::wstring & | str | ) |
Converts a wide Unicode string to a UTF-8 encoded string.
unsigned int StrUtils::Utf8CharToUnicode | ( | const std::string & | ch | ) |
Converts a UTF-8 encoded single character to wide Unicode char.
std::wstring StrUtils::Utf8StringToUnicode | ( | const std::string & | str | ) |
Converts a UTF-8 encoded string to wide Unicode string.
int StrUtils::Utf8CharSizeAt | ( | const std::string & | str, |
unsigned int | pos | ||
) |
Returns the size in bytes of UTF-8 character at given pos in a UTF-8 str.
std::size_t StrUtils::Utf8StringLength | ( | const std::string & | str | ) |
Returns the length in characters of UTF-8 string str.