#include "string.h"
#include "pointer.h"
#include "numeric.h"
#include "log.h"
#include "hex.h"
#include "porting.h"
#include "translation.h"
#include <algorithm>
#include <array>
#include <sstream>
#include <iomanip>
#include <map>
#include <iconv.h>
Classes | |
struct | ColorContainer |
Functions | |
static bool | parseHexColorString (const std::string &value, video::SColor &color, unsigned char default_alpha=0xff) |
static bool | parseNamedColorString (const std::string &value, video::SColor &color) |
static bool | convert (const char *to, const char *from, char *outbuf, size_t *outbuf_size, char *inbuf, size_t inbuf_size) |
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) |
void | str_replace (std::string &str, char from, char to) |
Replace all occurrences of the character from in str with to . More... | |
void | translate_all (const std::wstring &s, size_t &i, Translations *translations, std::wstring &res) |
void | translate_string (const std::wstring &s, Translations *translations, const std::wstring &textdomain, size_t &i, std::wstring &res) |
std::wstring | translate_string (const std::wstring &s, Translations *translations) |
std::wstring | translate_string (const std::wstring &s) |
std::string | sanitizeDirName (const std::string &str, const std::string &optional_prefix) |
Sanitize the name of a new directory. More... | |
Variables | |
const char * | DEFAULT_ENCODING = "WCHAR_T" |
static const ColorContainer | named_colors |
static const std::array< std::wstring, 22 > | disallowed_dir_names |
static const std::wstring | disallowed_path_chars = L"<>:\"/\\|?*." |
List of characters that are blacklisted from created directories. More... | |
|
static |
size_t mystrlcpy | ( | char * | dst, |
const char * | src, | ||
size_t | size | ||
) |
References MYMIN.
char* mystrtok_r | ( | char * | s, |
const char * | sep, | ||
char ** | lasts | ||
) |
bool parseColorString | ( | const std::string & | value, |
video::SColor & | color, | ||
bool | quiet, | ||
unsigned char | default_alpha | ||
) |
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().
|
static |
References hex_digit_decode().
Referenced by parseColorString().
|
static |
References ColorContainer::colors, hex_digit_decode(), lowercase(), and named_colors.
Referenced by parseColorString().
u64 read_seed | ( | const char * | str | ) |
References murmur_hash_64_ua().
Referenced by MapgenParams::readParams().
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().
std::string sanitizeDirName | ( | const std::string & | str, |
const std::string & | optional_prefix | ||
) |
Sanitize the name of a new directory.
This consists of two stages:
References disallowed_dir_names, disallowed_path_chars, str_equal(), utf8_to_wide(), and wide_to_utf8().
Referenced by ModApiMainMenu::l_create_world().
void str_replace | ( | std::string & | str, |
char | from, | ||
char | to | ||
) |
Replace all occurrences of the character from
in str
with to
.
str | The string to (potentially) modify. |
from | The character in str to replace. |
to | The replacement character. |
Referenced by TextureSource::generateImagePart(), Client::initLocalMapSaving(), and TestUtilities::testStringReplace().
void translate_all | ( | const std::wstring & | s, |
size_t & | i, | ||
Translations * | translations, | ||
std::wstring & | res | ||
) |
References split(), and translate_string().
Referenced by translate_string().
std::wstring translate_string | ( | const std::wstring & | s | ) |
std::wstring translate_string | ( | const std::wstring & | s, |
Translations * | translations | ||
) |
References translate_all().
Referenced by unescape_translate().
void translate_string | ( | const std::wstring & | s, |
Translations * | translations, | ||
const std::wstring & | textdomain, | ||
size_t & | i, | ||
std::wstring & | res | ||
) |
References errorstream, Translations::getTranslation(), split(), translate_all(), and wide_to_utf8().
Referenced by ChatBackend::addMessage(), Camera::drawNametags(), ModApiEnvMod::l_get_translated_string(), EnrichedString::operator=(), GUIFormSpecMenu::parseButton(), GUIFormSpecMenu::parseCheckbox(), GUIFormSpecMenu::parseHyperText(), GUIFormSpecMenu::parseLabel(), GUIFormSpecMenu::parsePwdField(), GUIFormSpecMenu::parseSimpleField(), GUIFormSpecMenu::parseTextArea(), GUIEngine::setTopleftText(), translate_all(), and translate_string().
std::string urldecode | ( | const std::string & | str | ) |
References hex_digit_decode().
Referenced by TestUtilities::testUrlDecode().
std::string urlencode | ( | const std::string & | str | ) |
Referenced by HTTPFetchOngoing::HTTPFetchOngoing(), and TestUtilities::testUrlEncode().
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().
wchar_t* utf8_to_wide_c | ( | const char * | str | ) |
References utf8_to_wide().
Referenced by GUIConfirmRegistration::regenerateGui(), and wgettext().
std::string wide_to_utf8 | ( | const std::wstring & | input | ) |
References convert(), DEFAULT_ENCODING, hex_encode(), and infostream.
Referenced by GUIFileSelectMenu::acceptInput(), GUIFormSpecMenu::acceptInput(), EnrichedString::addAtEnd(), Translations::getTranslation(), TextDestNodeMetadata::gotText(), TextDestGuiEngine::gotText(), Server::handleChat(), Client::handleCommand_AccessDenied(), Client::handleCommand_ChatMessage(), ModApiEnvMod::l_get_translated_string(), Translations::loadTranslation(), GUIChatConsole::OnEvent(), GUIFormSpecMenu::parseTable(), GUIFormSpecMenu::parseTextList(), GUIModalMenu::preprocessEvent(), GUIPasswordChange::processInput(), Server::requestShutdown(), sanitizeDirName(), stringw_to_utf8(), TestUtilities::testUTF8(), Server::ShutdownState::tick(), translate_string(), and Client::typeChatMessage().
std::string writeFlagString | ( | u32 | flags, |
const FlagDesc * | flagdesc, | ||
u32 | flagmask | ||
) |
References FlagDesc::name.
Referenced by push_flags_string(), Settings::setDefault(), and Settings::setFlagStr().
const char* DEFAULT_ENCODING = "WCHAR_T" |
Referenced by utf8_to_wide(), and wide_to_utf8().
|
static |
Referenced by sanitizeDirName().
|
static |
List of characters that are blacklisted from created directories.
Referenced by sanitizeDirName().
|
static |
Referenced by parseNamedColorString().