Minetest  5.4.0
string.h File Reference
#include "irrlichttypes_bloated.h"
#include "irrString.h"
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <sstream>
#include <iomanip>
#include <cctype>
#include <unordered_map>
+ Include dependency graph for string.h:

Go to the source code of this file.

Classes

struct  FlagDesc
 

Macros

#define STRINGIFY(x)   #x
 
#define TOSTRING(x)   STRINGIFY(x)
 
#define IS_ASCII_PRINTABLE_CHAR(x)
 
#define IS_UTF8_MULTB_INNER(x)
 
#define IS_UTF8_MULTB_START(x)
 
#define UTF8_MULTB_START_LEN(x)
 
#define stoi   mystoi
 
#define stof   mystof
 
#define DEFINE_STD_TOSTRING_FLOATINGPOINT(T)
 

Typedefs

typedef std::unordered_map< std::string, std::string > StringMap
 

Functions

std::wstring utf8_to_wide (const std::string &input)
 
std::string wide_to_utf8 (const std::wstring &input)
 
wchar_t * utf8_to_wide_c (const char *str)
 
std::string urlencode (const std::string &str)
 
std::string urldecode (const std::string &str)
 
u32 readFlagString (std::string str, const FlagDesc *flagdesc, u32 *flagmask)
 
std::string writeFlagString (u32 flags, const FlagDesc *flagdesc, u32 flagmask)
 
size_t mystrlcpy (char *dst, const char *src, size_t size)
 
char * mystrtok_r (char *s, const char *sep, char **lasts)
 
u64 read_seed (const char *str)
 
bool parseColorString (const std::string &value, video::SColor &color, bool quiet, unsigned char default_alpha=0xff)
 
std::string padStringRight (std::string str, size_t len)
 Returns a copy of str with spaces inserted at the right hand side to ensure that the string is len characters in length. More...
 
std::string removeStringEnd (const std::string &str, const char *ends[])
 Returns a version of str with the first occurrence of a string contained within ends[] removed from the end of the string. More...
 
template<typename T >
bool str_equal (const std::basic_string< T > &s1, const std::basic_string< T > &s2, bool case_insensitive=false)
 Check two strings for equivalence. More...
 
template<typename T >
bool str_starts_with (const std::basic_string< T > &str, const std::basic_string< T > &prefix, bool case_insensitive=false)
 Check whether str begins with the string prefix. More...
 
template<typename T >
bool str_starts_with (const std::basic_string< T > &str, const T *prefix, bool case_insensitive=false)
 Check whether str begins with the string prefix. More...
 
template<typename T >
bool str_ends_with (const std::basic_string< T > &str, const std::basic_string< T > &suffix, bool case_insensitive=false)
 Check whether str ends with the string suffix. More...
 
template<typename T >
bool str_ends_with (const std::basic_string< T > &str, const T *suffix, bool case_insensitive=false)
 Check whether str ends with the string suffix. More...
 
template<typename T >
std::vector< std::basic_string< T > > str_split (const std::basic_string< T > &str, T delimiter)
 Splits a string into its component parts separated by the character delimiter. More...
 
std::string lowercase (const std::string &str)
 
std::string trim (const std::string &str)
 
bool is_yes (const std::string &str)
 Returns whether str should be regarded as (bool) true. More...
 
s32 mystoi (const std::string &str, s32 min, s32 max)
 Converts the string str to a signed 32-bit integer. More...
 
s32 mystoi (const std::string &str)
 Returns a 32-bit value reprensented by the string str (decimal). More...
 
float mystof (const std::string &str)
 Returns a float reprensented by the string str (decimal). More...
 
template<typename T >
from_string (const std::string &str)
 Returns a value represented by the string val. More...
 
s64 stoi64 (const std::string &str)
 Returns a 64-bit signed value represented by the string str (decimal). More...
 
template<typename T >
string std::to_string (T val)
 Returns a string representing the value val. More...
 
template<typename T >
wstring std::to_wstring (T val)
 Returns a wide string representing the value val. More...
 
std::string itos (s32 i)
 Returns a string representing the decimal value of the 32-bit value i. More...
 
std::string i64tos (s64 i)
 Returns a string representing the decimal value of the 64-bit value i. More...
 
std::string ftos (float f)
 Returns a string representing the decimal value of the float value f. More...
 
void str_replace (std::string &str, const std::string &pattern, const std::string &replacement)
 Replace all occurrences of pattern in str with replacement. More...
 
void str_formspec_escape (std::string &str)
 Escapes characters [ ] \ , ; that can not be used in formspecs. More...
 
void str_replace (std::string &str, char from, char to)
 Replace all occurrences of the character from in str with to. More...
 
bool string_allowed (const std::string &str, const std::string &allowed_chars)
 Check that a string only contains whitelisted characters. More...
 
bool string_allowed_blacklist (const std::string &str, const std::string &blacklisted_chars)
 Check that a string contains no blacklisted characters. More...
 
std::string wrap_rows (const std::string &from, unsigned row_len)
 Create a string based on from where a newline is forcefully inserted every row_len characters. More...
 
template<typename T >
std::basic_string< T > unescape_string (const std::basic_string< T > &s)
 Removes backslashes from an escaped string (FormSpec strings) More...
 
template<typename T >
std::basic_string< T > unescape_enriched (const std::basic_string< T > &s)
 Remove all escape sequences in s. More...
 
template<typename T >
std::vector< std::basic_string< T > > split (const std::basic_string< T > &s, T delim)
 
std::wstring translate_string (const std::wstring &s, Translations *translations)
 
std::wstring translate_string (const std::wstring &s)
 
std::wstring unescape_translate (const std::wstring &s)
 
bool is_number (const std::string &to_check)
 Checks that all characters in to_check are a decimal digits. More...
 
const char * bool_to_cstr (bool val)
 Returns a C-string, either "true" or "false", corresponding to val. More...
 
const std::string duration_to_string (int sec)
 
std::string str_join (const std::vector< std::string > &list, const std::string &delimiter)
 Joins a vector of strings by the string delimiter. More...
 
std::string stringw_to_utf8 (const irr::core::stringw &input)
 Create a UTF8 std::string from a irr::core::stringw. More...
 
irr::core::stringw utf8_to_stringw (const std::string &input)
 Create a irr::core:stringw from a UTF8 std::string. More...
 
std::string sanitizeDirName (const std::string &str, const std::string &optional_prefix)
 Sanitize the name of a new directory. More...
 

Macro Definition Documentation

◆ DEFINE_STD_TOSTRING_FLOATINGPOINT

#define DEFINE_STD_TOSTRING_FLOATINGPOINT (   T)
Value:
template <> \
inline string to_string<T>(T val) \
{ \
ostringstream oss; \
oss << std::fixed \
<< std::setprecision(6) \
<< val; \
return oss.str(); \
}

◆ IS_ASCII_PRINTABLE_CHAR

#define IS_ASCII_PRINTABLE_CHAR (   x)
Value:
(((unsigned int)(x) >= 0x20) && \
( (unsigned int)(x) <= 0x7e))

◆ IS_UTF8_MULTB_INNER

#define IS_UTF8_MULTB_INNER (   x)
Value:
(((unsigned char)(x) >= 0x80) && \
( (unsigned char)(x) <= 0xbf))

◆ IS_UTF8_MULTB_START

#define IS_UTF8_MULTB_START (   x)
Value:
(((unsigned char)(x) >= 0xc2) && \
( (unsigned char)(x) <= 0xf4))

◆ stof

#define stof   mystof

◆ stoi

#define stoi   mystoi

◆ STRINGIFY

#define STRINGIFY (   x)    #x

◆ TOSTRING

#define TOSTRING (   x)    STRINGIFY(x)

◆ UTF8_MULTB_START_LEN

#define UTF8_MULTB_START_LEN (   x)
Value:
(((unsigned char)(x) < 0xe0) ? 2 : \
(((unsigned char)(x) < 0xf0) ? 3 : 4))

Typedef Documentation

◆ StringMap

typedef std::unordered_map<std::string, std::string> StringMap

Function Documentation

◆ bool_to_cstr()

const char* bool_to_cstr ( bool  val)
inline

Returns a C-string, either "true" or "false", corresponding to val.

Returns
If val is true, then "true" is returned, otherwise "false".

Referenced by Game::toggleAutoforward(), Game::toggleCinematic(), Game::toggleFast(), Game::toggleFreeMove(), Game::toggleNoClip(), and Game::togglePitchMove().

+ Here is the caller graph for this function:

◆ duration_to_string()

const std::string duration_to_string ( int  sec)
inline

Referenced by Server::ShutdownState::getShutdownTimerMessage(), and Server::requestShutdown().

+ Here is the caller graph for this function:

◆ from_string()

template<typename T >
T from_string ( const std::string &  str)
inline

Returns a value represented by the string val.

◆ ftos()

std::string ftos ( float  f)
inline

Returns a string representing the decimal value of the float value f.

Referenced by content_nodemeta_deserialize_legacy_body(), QuicktuneValue::getString(), MetaDataRef::l_set_float(), and Settings::setFloat().

+ Here is the caller graph for this function:

◆ i64tos()

std::string i64tos ( s64  i)
inline

Returns a string representing the decimal value of the 64-bit value i.

Referenced by Database_LevelDB::deleteBlock(), Database_Redis::deleteBlock(), Database_LevelDB::loadBlock(), Database_Redis::loadBlock(), Database_LevelDB::saveBlock(), and Database_Redis::saveBlock().

+ Here is the caller graph for this function:

◆ is_number()

bool is_number ( const std::string &  to_check)
inline

Checks that all characters in to_check are a decimal digits.

Parameters
to_check
Returns
true if to_check is not empty and all characters in to_check are decimal digits, otherwise false

Referenced by TextureSource::generateImagePart(), GUIFormSpecMenu::parseVersionDirect(), and TestUtilities::testIsNumber().

+ Here is the caller graph for this function:

◆ is_yes()

bool is_yes ( const std::string &  str)
inline

Returns whether str should be regarded as (bool) true.

Case and leading and trailing whitespace are ignored. Values that will return true are "y", "yes", "true" and any number that is not 0.

Parameters
str

References lowercase(), and trim().

Referenced by Settings::getBool(), StyleSpec::getBool(), ModApiUtil::Initialize(), ModApiUtil::InitializeAsync(), ModApiUtil::InitializeClient(), ModApiUtil::l_is_yes(), GUIFormSpecMenu::parseBackground(), GUIFormSpecMenu::parseBackgroundColor(), GUIFormSpecMenu::parseDropDown(), GUIFormSpecMenu::parseElement(), GUIFormSpecMenu::parseFieldCloseOnEnter(), ParsedText::parseGenericStyleAttr(), GUIFormSpecMenu::parseModel(), GUIFormSpecMenu::parseSetFocus(), ParsedText::parseTag(), GUIFormSpecMenu::parseTextList(), FontEngine::readSettings(), GUIFormSpecMenu::regenerateGui(), ParsedText::Element::setStyle(), GUITable::setTable(), and TestUtilities::testIsYes().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ itos()

◆ lowercase()

std::string lowercase ( const std::string &  str)
inline
Parameters
str
Returns
A copy of str converted to all lowercase characters.

Referenced by gen_srp_v(), init_gettext(), FontEngine::initSimpleFont(), is_yes(), parseImageTransform(), parseNamedColorString(), JoystickController::setLayoutFromControllerName(), porting::setSystemPaths(), Client::startAuth(), and TestUtilities::testLowercase().

+ Here is the caller graph for this function:

◆ mystof()

float mystof ( const std::string &  str)
inline

Returns a float reprensented by the string str (decimal).

See also
atof(3)

◆ mystoi() [1/2]

s32 mystoi ( const std::string &  str)
inline

Returns a 32-bit value reprensented by the string str (decimal).

See also
atoi(3) for further limitations

◆ mystoi() [2/2]

s32 mystoi ( const std::string &  str,
s32  min,
s32  max 
)
inline

Converts the string str to a signed 32-bit integer.

The converted value is constrained so that min <= value <= max.

See also
atoi(3) for limitations
Parameters
str
minRange minimum
maxRange maximum
Returns
The value converted to a signed 32-bit integer and constrained within the range defined by min and max (inclusive)

Referenced by TextureSource::generateImagePart(), CItemDefManager::getItemstackColor(), Game::nodePlacement(), GUIFormSpecMenu::parseVersionDirect(), and TestUtilities::testStrToIntConversion().

+ Here is the caller graph for this function:

◆ mystrlcpy()

size_t mystrlcpy ( char *  dst,
const char *  src,
size_t  size 
)

References MYMIN.

◆ mystrtok_r()

char* mystrtok_r ( char *  s,
const char *  sep,
char **  lasts 
)

◆ padStringRight()

std::string padStringRight ( std::string  str,
size_t  len 
)
inline

Returns a copy of str with spaces inserted at the right hand side to ensure that the string is len characters in length.

If str is <= len then the returned string will be identical to str.

Referenced by print_allowed_options(), and TestUtilities::testPadString().

+ Here is the caller graph for this function:

◆ parseColorString()

bool parseColorString ( const std::string &  value,
video::SColor &  color,
bool  quiet,
unsigned char  default_alpha = 0xff 
)

References errorstream, parseHexColorString(), and parseNamedColorString().

Referenced by EnrichedString::addAtEnd(), check_color(), TextureSource::generateImagePart(), StyleSpec::getColor(), StyleSpec::getColorArray(), CItemDefManager::getItemstackColor(), ParsedText::globalTag(), GUIFormSpecMenu::parseBackgroundColor(), GUIFormSpecMenu::parseBox(), GUIFormSpecMenu::parseListColors(), GUIFormSpecMenu::parseTooltip(), read_color(), ParsedText::Element::setStyle(), GUITable::setTable(), and GUITable::setTextList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read_seed()

u64 read_seed ( const char *  str)

References murmur_hash_64_ua().

Referenced by MapgenParams::readParams().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readFlagString()

u32 readFlagString ( std::string  str,
const FlagDesc flagdesc,
u32 *  flagmask 
)

References FlagDesc::flag, and FlagDesc::name.

Referenced by Settings::getFlagStr(), read_flags(), and TestSettings::testFlagDesc().

+ Here is the caller graph for this function:

◆ removeStringEnd()

std::string removeStringEnd ( const std::string &  str,
const char *  ends[] 
)
inline

Returns a version of str with the first occurrence of a string contained within ends[] removed from the end of the string.

Parameters
str
endsA NULL- or ""- terminated array of strings to remove from s in the copy produced. Note that once one of these strings is removed that no further postfixes contained within this array are removed.
Returns
If no end could be removed then "" is returned.

References p().

Referenced by Server::addMediaFile(), porting::detectMSVCBuildDir(), getAvailableGameIds(), getImagePath(), Client::loadMedia(), and TestUtilities::testRemoveStringEnd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sanitizeDirName()

std::string sanitizeDirName ( const std::string &  str,
const std::string &  optional_prefix 
)

Sanitize the name of a new directory.

This consists of two stages:

  1. Check for 'reserved filenames' that can't be used on some filesystems and prefix them
  2. Remove 'unsafe' characters from the name by replacing them with '_'

    This consists of two stages:

  1. Check for 'reserved filenames' that can't be used on some filesystems and add a prefix to them
  2. Remove 'unsafe' characters from the name by replacing them with '_'

References disallowed_dir_names, disallowed_path_chars, str_equal(), utf8_to_wide(), and wide_to_utf8().

Referenced by ModApiMainMenu::l_create_world().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ split()

template<typename T >
std::vector<std::basic_string<T> > split ( const std::basic_string< T > &  s,
delim 
)

Referenced by EnrichedString::addAtEnd(), StyleSpec::getFont(), GUIFormSpecMenu::parseAnchor(), GUIFormSpecMenu::parseAnchorDirect(), GUIFormSpecMenu::parseAnimatedImage(), StyleSpec::parseArray(), GUIFormSpecMenu::parseBackground(), GUIFormSpecMenu::parseBackgroundColor(), GUIFormSpecMenu::parseBox(), GUIFormSpecMenu::parseButton(), GUIFormSpecMenu::parseCheckbox(), GUIFormSpecMenu::parseContainer(), GUIFormSpecMenu::parseDropDown(), GUIFormSpecMenu::parseField(), GUIFormSpecMenu::parseFieldCloseOnEnter(), GUIFormSpecMenu::parseHyperText(), GUIFormSpecMenu::parseImage(), GUIFormSpecMenu::parseImageButton(), GUIFormSpecMenu::parseItemImage(), GUIFormSpecMenu::parseItemImageButton(), GUIFormSpecMenu::parseLabel(), GUIFormSpecMenu::parseList(), GUIFormSpecMenu::parseListColors(), GUIFormSpecMenu::parseListRing(), GUIFormSpecMenu::parseModel(), GUIFormSpecMenu::parsePosition(), GUIFormSpecMenu::parsePositionDirect(), GUIFormSpecMenu::parsePwdField(), StyleSpec::parseRect(), GUIFormSpecMenu::parseScrollBar(), GUIFormSpecMenu::parseScrollBarOptions(), GUIFormSpecMenu::parseScrollContainer(), GUIFormSpecMenu::parseSetFocus(), GUIFormSpecMenu::parseSize(), GUIFormSpecMenu::parseSizeDirect(), GUIFormSpecMenu::parseStyle(), GUIFormSpecMenu::parseTabHeader(), GUIFormSpecMenu::parseTable(), GUIFormSpecMenu::parseTableColumns(), GUIFormSpecMenu::parseTableOptions(), ParsedText::parseTag(), GUIFormSpecMenu::parseTextArea(), GUIFormSpecMenu::parseTextList(), GUIFormSpecMenu::parseTooltip(), StyleSpec::parseVector2f(), GUIFormSpecMenu::parseVersionDirect(), GUIFormSpecMenu::parseVertLabel(), GUIFormSpecMenu::regenerateGui(), translate_all(), and translate_string().

◆ stoi64()

s64 stoi64 ( const std::string &  str)
inline

Returns a 64-bit signed value represented by the string str (decimal).

Referenced by Database_LevelDB::listAllLoadableBlocks(), and Database_Redis::listAllLoadableBlocks().

+ Here is the caller graph for this function:

◆ str_ends_with() [1/2]

template<typename T >
bool str_ends_with ( const std::basic_string< T > &  str,
const std::basic_string< T > &  suffix,
bool  case_insensitive = false 
)
inline

Check whether str ends with the string suffix.

If case_insensitive is true then the check is case insensitve (default is false; i.e. case is significant).

Parameters
str
suffix
case_insensitive
Returns
true if the str begins with suffix

Referenced by Server::getTranslationLanguage(), Server::sendMediaAnnouncement(), and str_ends_with().

+ Here is the caller graph for this function:

◆ str_ends_with() [2/2]

template<typename T >
bool str_ends_with ( const std::basic_string< T > &  str,
const T *  suffix,
bool  case_insensitive = false 
)
inline

Check whether str ends with the string suffix.

If case_insensitive is true then the check is case insensitve (default is false; i.e. case is significant).

Parameters
str
suffix
case_insensitive
Returns
true if the str begins with suffix

References str_ends_with().

+ Here is the call graph for this function:

◆ str_equal()

template<typename T >
bool str_equal ( const std::basic_string< T > &  s1,
const std::basic_string< T > &  s2,
bool  case_insensitive = false 
)
inline

Check two strings for equivalence.

If case_insensitive is true then the case of the strings is ignored (default is false).

Parameters
s1
s2
case_insensitive
Returns
true if the strings match

Referenced by ChatPrompt::nickCompletion(), sanitizeDirName(), and TestUtilities::testStrEqual().

+ Here is the caller graph for this function:

◆ str_formspec_escape()

void str_formspec_escape ( std::string &  str)
inline

Escapes characters [ ] \ , ; that can not be used in formspecs.

References str_replace().

Referenced by Game::showPauseMenu().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ str_join()

std::string str_join ( const std::vector< std::string > &  list,
const std::string &  delimiter 
)
inline

Joins a vector of strings by the string delimiter.

Returns
A std::string

Referenced by TestAuthDatabase::testListNames(), TestAuthDatabase::testRecall(), TestAuthDatabase::testRecallChanged(), TestAuthDatabase::testRecallChangedPrivileges(), TestUtilities::testStringJoin(), and AuthDatabaseFiles::writeAuthFile().

+ Here is the caller graph for this function:

◆ str_replace() [1/2]

void str_replace ( std::string &  str,
char  from,
char  to 
)

Replace all occurrences of the character from in str with to.

Parameters
strThe string to (potentially) modify.
fromThe character in str to replace.
toThe replacement character.

Referenced by TextureSource::generateImagePart(), Client::initLocalMapSaving(), and TestUtilities::testStringReplace().

+ Here is the caller graph for this function:

◆ str_replace() [2/2]

void str_replace ( std::string &  str,
const std::string &  pattern,
const std::string &  replacement 
)
inline

Replace all occurrences of pattern in str with replacement.

Parameters
strString to replace pattern with replacement within.
patternThe pattern to replace.
replacementWhat to replace the pattern with.

Referenced by str_formspec_escape().

+ Here is the caller graph for this function:

◆ str_split()

template<typename T >
std::vector<std::basic_string<T> > str_split ( const std::basic_string< T > &  str,
delimiter 
)
inline

Splits a string into its component parts separated by the character delimiter.

Returns
An std::vector<std::basic_string<T> > of the component parts

Referenced by TextureOverrideSource::TextureOverrideSource(), decode_srp_verifier_and_salt(), Server::handleCommand_Init(), ModApiHttp::l_request_http_api(), ModApiUtil::l_request_insecure_environment(), LBMManager::loadIntroductionTimes(), Translations::loadTranslation(), parseModContents(), and AuthDatabaseFiles::readAuthFile().

+ Here is the caller graph for this function:

◆ str_starts_with() [1/2]

template<typename T >
bool str_starts_with ( const std::basic_string< T > &  str,
const std::basic_string< T > &  prefix,
bool  case_insensitive = false 
)
inline

Check whether str begins with the string prefix.

If case_insensitive is true then the check is case insensitve (default is false; i.e. case is significant).

Parameters
str
prefix
case_insensitive
Returns
true if the str begins with prefix

Referenced by TextureSource::generateImagePart(), isGroupRecipeStr(), Translations::loadTranslation(), ChatPrompt::nickCompletion(), str_starts_with(), and TestUtilities::testStartsWith().

+ Here is the caller graph for this function:

◆ str_starts_with() [2/2]

template<typename T >
bool str_starts_with ( const std::basic_string< T > &  str,
const T *  prefix,
bool  case_insensitive = false 
)
inline

Check whether str begins with the string prefix.

If case_insensitive is true then the check is case insensitve (default is false; i.e. case is significant).

Parameters
str
prefix
case_insensitive
Returns
true if the str begins with prefix

References str_starts_with().

+ Here is the call graph for this function:

◆ string_allowed()

bool string_allowed ( const std::string &  str,
const std::string &  allowed_chars 
)
inline

Check that a string only contains whitelisted characters.

This is the opposite of string_allowed_blacklist().

Parameters
strThe string to be checked.
allowed_charsA string containing permitted characters.
Returns
true if the string is allowed, otherwise false.
See also
string_allowed_blacklist()

Referenced by ClientMediaDownloader::addFile(), LBMManager::addLBMDef(), Server::addMediaFile(), Server::handleCommand_Init(), Client::handleCommand_MediaPush(), Client::loadMods(), ServerModManager::loadMods(), parseDependsString(), run_dedicated_server(), GUITable::setTable(), and TestUtilities::testStringAllowed().

+ Here is the caller graph for this function:

◆ string_allowed_blacklist()

bool string_allowed_blacklist ( const std::string &  str,
const std::string &  blacklisted_chars 
)
inline

Check that a string contains no blacklisted characters.

This is the opposite of string_allowed().

Parameters
strThe string to be checked.
blacklisted_charsA string containing prohibited characters.
Returns
true if the string is allowed, otherwise false.
See also
string_allowed()

Referenced by TestUtilities::testStringAllowed().

+ Here is the caller graph for this function:

◆ stringw_to_utf8()

std::string stringw_to_utf8 ( const irr::core::stringw &  input)
inline

Create a UTF8 std::string from a irr::core::stringw.

References wide_to_utf8().

Referenced by TextDrawer::TextDrawer(), TextDrawer::draw(), and ParsedText::parseTag().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ to_string()

template<typename T >
string std::to_string ( val)
inline

Returns a string representing the value val.

References std::to_string().

Referenced by std::to_string(), and std::to_wstring().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ to_wstring()

template<typename T >
wstring std::to_wstring ( val)
inline

Returns a wide string representing the value val.

References std::to_string(), std::to_wstring(), and utf8_to_wide().

Referenced by std::to_wstring().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ translate_string() [1/2]

std::wstring translate_string ( const std::wstring &  s)

References g_client_translations, and translate_string().

+ Here is the call graph for this function:

◆ translate_string() [2/2]

std::wstring translate_string ( const std::wstring &  s,
Translations translations 
)

References translate_all().

Referenced by unescape_translate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ trim()

◆ unescape_enriched()

template<typename T >
std::basic_string<T> unescape_enriched ( const std::basic_string< T > &  s)

Remove all escape sequences in s.

Parameters
sThe string in which to remove escape sequences.
Returns
s, with escape sequences removed.

Referenced by Server::handleChat(), GUIFormSpecMenu::parseLabel(), and unescape_translate().

+ Here is the caller graph for this function:

◆ unescape_string()

◆ unescape_translate()

std::wstring unescape_translate ( const std::wstring &  s)
inline

References translate_string(), and unescape_enriched().

Referenced by Hud::drawLuaElements(), Camera::drawNametags(), Game::handlePointingAtNode(), Game::handlePointingAtObject(), GUIFormSpecMenu::parseDropDown(), GUIFormSpecMenu::parseTabHeader(), GUIFormSpecMenu::parseTable(), GUIFormSpecMenu::parseTextList(), and GUIFormSpecMenu::parseVertLabel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ urldecode()

std::string urldecode ( const std::string &  str)

References hex_digit_decode().

Referenced by TestUtilities::testUrlDecode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ urlencode()

std::string urlencode ( const std::string &  str)

Referenced by HTTPFetchOngoing::HTTPFetchOngoing(), and TestUtilities::testUrlEncode().

+ Here is the caller graph for this function:

◆ utf8_to_stringw()

irr::core::stringw utf8_to_stringw ( const std::string &  input)
inline

Create a irr::core:stringw from a UTF8 std::string.

References utf8_to_wide().

Referenced by GUIHyperText::OnEvent(), and ParsedText::parseTag().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ utf8_to_wide()

std::wstring utf8_to_wide ( const std::string &  input)

References convert(), DEFAULT_ENCODING, hex_encode(), infostream, and SANITY_CHECK.

Referenced by GUITable::allocString(), Game::createClient(), ProfilerGraph::draw(), drawItemStack(), Hud::drawLuaElements(), GUIFormSpecMenu::drawMenu(), Camera::drawNametags(), Game::getServerContent(), FontEngine::getTextWidth(), Server::handleChat(), Game::handlePointingAtNode(), Game::handlePointingAtObject(), GameUI::init(), ModApiServer::l_chat_send_all(), ModApiServer::l_chat_send_player(), ModApiClient::l_display_chat_message(), ModApiEnvMod::l_get_translated_string(), ModApiServer::l_kick_player(), ModApiClient::l_send_chat_message(), Translations::loadTranslation(), Client::makeScreenshot(), ChatPrompt::nickCompletion(), GUIFormSpecMenu::parseButton(), GUIFormSpecMenu::parseCheckbox(), GUIFormSpecMenu::parseDropDown(), GUIFormSpecMenu::parseHyperText(), GUIFormSpecMenu::parseImageButton(), GUIFormSpecMenu::parseItemImageButton(), GUIFormSpecMenu::parseLabel(), GUIFormSpecMenu::parsePwdField(), GUIFormSpecMenu::parseSimpleField(), GUIFormSpecMenu::parseTabHeader(), GUIFormSpecMenu::parseTable(), GUIFormSpecMenu::parseTextArea(), GUIFormSpecMenu::parseTextList(), GUIFormSpecMenu::parseTooltip(), GUIFormSpecMenu::parseVertLabel(), Server::printToConsoleOnly(), Server::ProcessData(), GUIConfirmRegistration::processInput(), Game::processKeyInput(), ClientLauncher::run(), sanitizeDirName(), GUIEngine::setTopleftText(), TestUtilities::testStrEqual(), TestUtilities::testUTF8(), TestUtilities::testWrapRows(), std::to_wstring(), Game::toggleMinimap(), GameUI::update(), Game::updateChat(), GameUI::updateProfiler(), utf8_to_stringw(), and utf8_to_wide_c().

+ Here is the call graph for this function:

◆ utf8_to_wide_c()

wchar_t* utf8_to_wide_c ( const char *  str)

◆ wide_to_utf8()

◆ wrap_rows()

std::string wrap_rows ( const std::string &  from,
unsigned  row_len 
)
inline

Create a string based on from where a newline is forcefully inserted every row_len characters.

Note
This function does not honour word wraps and blindy inserts a newline every row_len characters whether it breaks a word or not. It is intended to be used for, for example, showing paths in the GUI.
This function doesn't wrap inside utf-8 multibyte sequences and also counts multibyte sequences correcly as single characters.
Parameters
fromThe (utf-8) string to be wrapped into rows.
row_lenThe row length (in characters).
Returns
A new string with the wrapping applied.

References IS_UTF8_MULTB_INNER.

Referenced by TestUtilities::testWrapRows().

+ Here is the caller graph for this function:

◆ writeFlagString()

std::string writeFlagString ( u32  flags,
const FlagDesc flagdesc,
u32  flagmask 
)

References FlagDesc::name.

Referenced by push_flags_string(), Settings::setDefault(), and Settings::setFlagStr().

+ Here is the caller graph for this function: