OpenTTD
|
Functions related to low-level strings. More...
Go to the source code of this file.
Functions | |
char * | strecat (char *dst, const char *src, const char *last) |
Appends characters from one string to another. | |
char * | strecpy (char *dst, const char *src, const char *last) |
Copies characters from one buffer to another. | |
char * | stredup (const char *src, const char *last=NULL) |
Create a duplicate of the given string. | |
int CDECL | seprintf (char *str, const char *last, const char *format,...) WARN_FORMAT(3 |
int CDECL int CDECL | vseprintf (char *str, const char *last, const char *format, va_list ap) |
Safer implementation of vsnprintf; same as vsnprintf except: | |
char *CDECL | str_fmt (const char *str,...) WARN_FORMAT(1 |
char *CDECL void | str_validate (char *str, const char *last, StringValidationSettings settings=SVS_REPLACE_WITH_QUESTION_MARK) |
Scans the string for valid characters and if it finds invalid ones, replaces them with a question mark '?' (if not ignored) | |
void | ValidateString (const char *str) |
Scans the string for valid characters and if it finds invalid ones, replaces them with a question mark '?'. | |
void | str_fix_scc_encoded (char *str, const char *last) |
Scan the string for old values of SCC_ENCODED and fix it to it's new, static value. | |
void | str_strip_colours (char *str) |
Scans the string for colour codes and strips them. | |
bool | strtolower (char *str) |
Convert a given ASCII string to lowercase. | |
bool | StrValid (const char *str, const char *last) |
Checks whether the given string is valid, i.e. | |
static bool | StrEmpty (const char *s) |
Check if a string buffer is empty. | |
static size_t | ttd_strnlen (const char *str, size_t maxlen) |
Get the length of a string, within a limited buffer. | |
char * | md5sumToString (char *buf, const char *last, const uint8 md5sum[16]) |
Convert the md5sum to a hexadecimal string representation. | |
bool | IsValidChar (WChar key, CharSetFilter afilter) |
Only allow certain keys. | |
size_t | Utf8Decode (WChar *c, const char *s) |
Decode and consume the next UTF-8 encoded character. | |
size_t | Utf8Encode (char *buf, WChar c) |
Encode a unicode character and place it in the buffer. | |
size_t | Utf8TrimString (char *s, size_t maxlen) |
Properly terminate an UTF8 string to some maximum length. | |
static WChar | Utf8Consume (const char **s) |
static int8 | Utf8CharLen (WChar c) |
Return the length of a UTF-8 encoded character. | |
static int8 | Utf8EncodedCharLen (char c) |
Return the length of an UTF-8 encoded value based on a single char. | |
static bool | IsUtf8Part (char c) |
static char * | Utf8PrevChar (char *s) |
Retrieve the previous UNICODE character in an UTF-8 encoded string. | |
static const char * | Utf8PrevChar (const char *s) |
size_t | Utf8StringLength (const char *s) |
Get the length of an UTF-8 encoded string in number of characters and thus not the number of bytes that the encoded string contains. | |
static bool | Utf16IsLeadSurrogate (uint c) |
Is the given character a lead surrogate code point? | |
static bool | Utf16IsTrailSurrogate (uint c) |
Is the given character a lead surrogate code point? | |
static WChar | Utf16DecodeSurrogate (uint lead, uint trail) |
Convert an UTF-16 surrogate pair to the corresponding Unicode character. | |
static WChar | Utf16DecodeChar (const uint16 *c) |
Decode an UTF-16 character. | |
static bool | IsTextDirectionChar (WChar c) |
Is the given character a text direction character. | |
static bool | IsPrintable (WChar c) |
static bool | IsWhitespace (WChar c) |
Check whether UNICODE character is whitespace or not, i.e. | |
int | strnatcmp (const char *s1, const char *s2, bool ignore_garbage_at_front=false) |
Compares two strings using case insensitive natural sort. |
Functions related to low-level strings.
Definition in file string_func.h.
|
inlinestatic |
Is the given character a text direction character.
c | The character to test. |
Definition at line 210 of file string_func.h.
References CHAR_TD_LRE, CHAR_TD_LRM, CHAR_TD_LRO, CHAR_TD_PDF, CHAR_TD_RLE, CHAR_TD_RLM, and CHAR_TD_RLO.
Referenced by MissingGlyphSearcher::FindMissingGlyphs(), GetLayouter(), and FallbackParagraphLayout::NextLine().
bool IsValidChar | ( | WChar | key, |
CharSetFilter | afilter | ||
) |
Only allow certain keys.
You can define the filter to be used. This makes sure no invalid keys can get into an editbox, like BELL.
key | character to be checked |
afilter | the filter to use |
Definition at line 338 of file string.cpp.
References CS_ALPHA, CS_ALPHANUMERAL, CS_HEXADECIMAL, CS_NUMERAL, and CS_NUMERAL_SPACE.
Referenced by IConsoleCmdExec(), Textbuf::InsertString(), OskWindow::OnClick(), TranslateTTDPatchCodes(), and OskWindow::UpdateOskState().
|
inlinestatic |
Check whether UNICODE character is whitespace or not, i.e.
whether this is a potential line-break character.
c | UNICODE character to check |
Definition at line 242 of file string_func.h.
Referenced by IConsoleHistoryAdd(), DefaultStringIterator::Next(), FallbackParagraphLayout::NextLine(), DefaultStringIterator::Prev(), and StringFilter::SetFilterTerm().
char* md5sumToString | ( | char * | buf, |
const char * | last, | ||
const uint8 | md5sum[16] | ||
) |
Convert the md5sum to a hexadecimal string representation.
buf | buffer to put the md5sum into |
last | last character of buffer (usually lastof(buf)) |
md5sum | the md5sum itself |
Definition at line 416 of file string.cpp.
References seprintf().
Referenced by HandleSavegameLoadCrash(), IsGoodGRFConfigList(), MakePNGImage(), NetworkContentListWindow::OpenExternalSearch(), OutputContentState(), PrintGrfInfo(), and ClientNetworkGameSocketHandler::Receive_SERVER_CHECK_NEWGRFS().
void str_fix_scc_encoded | ( | char * | str, |
const char * | last | ||
) |
Scan the string for old values of SCC_ENCODED and fix it to it's new, static value.
str | the string to scan |
last | the last valid character of str |
Definition at line 158 of file string.cpp.
References Utf8Decode(), Utf8Encode(), and Utf8EncodedCharLen().
Referenced by SlString().
char* CDECL void str_validate | ( | char * | str, |
const char * | last, | ||
StringValidationSettings | settings | ||
) |
Scans the string for valid characters and if it finds invalid ones, replaces them with a question mark '?' (if not ignored)
str | the string to validate |
last | the last valid character of str |
settings | the settings for the string validation. |
Definition at line 184 of file string.cpp.
References SVS_ALLOW_CONTROL_CODE, SVS_ALLOW_NEWLINE, SVS_REPLACE_WITH_QUESTION_MARK, Utf8Decode(), and Utf8EncodedCharLen().
Referenced by FiosFileScanner::AddFile(), FiosGetFileList(), GetFileTitle(), IConsolePrint(), IniGroup::IniGroup(), IniItem::IniItem(), IniLoadFile::LoadFromDisk(), LoadFromHighScore(), TextfileWindow::LoadTextfile(), Packet::Recv_string(), SlString(), and ValidateString().
char* strecat | ( | char * | dst, |
const char * | src, | ||
const char * | last | ||
) |
Appends characters from one string to another.
Appends the source string to the destination string with respect of the terminating null-character and and the last pointer to the last element in the destination buffer. If the last pointer is set to NULL no boundary check is performed.
dst | The buffer containing the target string |
src | The buffer containing the string to append |
last | The pointer to the last element of the destination buffer |
Definition at line 73 of file string.cpp.
References strecpy().
char* strecpy | ( | char * | dst, |
const char * | src, | ||
const char * | last | ||
) |
Copies characters from one buffer to another.
Copies the source string to the destination buffer with respect of the terminating null-character and the last pointer to the last element in the destination buffer. If the last pointer is set to NULL no boundary check is performed.
dst | The destination buffer |
src | The buffer containing the string to copy |
last | The pointer to the last element of the destination buffer |
Definition at line 68 of file depend.cpp.
References DEBUG, and error().
Referenced by ScriptScanner::AddFile(), TarScanner::AddFile(), FiosFileScanner::AddFile(), ScenarioScanner::AddFile(), Textbuf::Assign(), BuildWithFullPath(), CloneVehicleName(), DriverFactoryBase::DriverFactoryBase(), DumpDebugFacilityNames(), ExtractTar(), GameScannerInfo::FindInfo(), AIScannerInfo::FindInfo(), FioCreateDirectory(), FioFOpenFile(), FiosGetFileList(), FiosMakeHeightmapName(), FormatNumber(), FormatString(), GamelogRevision(), GeneratePath(), GenerateTownNameString(), NetworkAddress::GetAddressAsString(), ServerNetworkGameSocketHandler::GetClientName(), GetClipboardContents(), GetFileTitle(), GetKeyboardLayout(), GetTextfile(), GRFBuildParamList(), FileStringReader::HandlePragma(), IConsoleAliasExec(), IniLoadSettings(), IniSaveSettings(), IsSameScript(), LoadTranslations(), main(), MakeAustrianTownName(), MakeCatalanTownName(), MakeCzechTownName(), MakeDanishTownName(), MakeDutchTownName(), MakeEnglishAdditionalTownName(), MakeEnglishOriginalTownName(), MakeFinnishTownName(), MakeFrenchTownName(), MakeGermanTownName(), MakeHungarianTownName(), MakeItalianTownName(), MakeNorwegianTownName(), MakePNGImage(), MakePolishTownName(), MakeRomanianTownName(), MakeScreenshot(), MakeScreenshotName(), MakeSillyTownName(), MakeSlovakTownName(), MakeSpanishTownName(), MakeSwedishTownName(), MakeSwissTownName(), MakeTurkishTownName(), mkpath(), NetworkAddChatMessage(), NetworkAddress::NetworkAddress(), NetworkFindBroadcastIPsInternal(), NetworkFindName(), NetworkGameListHandleDelayedInsert(), NetworkSendCommand(), NetworkServerChangeClientName(), NetworkServerSetCompanyPassword(), NetworkUDPQueryServer(), NetworkUpdateClientName(), SaveLoadWindow::OnClick(), NetworkGameWindow::OnEditboxChanged(), NetworkStartServerWindow::OnEditboxChanged(), AIDebugWindow::OnEditboxChanged(), NetworkStartServerWindow::OnQueryTextFinished(), CustomCurrencyWindow::OnQueryTextFinished(), ClientNetworkContentSocketHandler::OnReceiveData(), NetworkContentListWindow::OpenExternalSearch(), openttd_main(), StringReader::ParseFile(), MusicDriver_Win32::PlaySong(), MusicDriver_ExtMidi::PlaySong(), ReadLanguagePack(), StringListReader::ReadLine(), ServerNetworkUDPSocketHandler::Receive_CLIENT_FIND_SERVER(), ServerNetworkUDPSocketHandler::Receive_CLIENT_GET_NEWGRFS(), ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(), ServerNetworkGameSocketHandler::Receive_CLIENT_SET_NAME(), ClientNetworkGameSocketHandler::Receive_SERVER_CLIENT_INFO(), ReconsiderGameScriptLanguage(), SquirrelStd::require(), NetworkAddress::Resolve(), IniFile::SaveToDisk(), FileScanner::Scan(), ScanFile(), Script_CreateDummy(), DriverFactoryBase::SelectDriverImpl(), ServerNetworkGameSocketHandler::SendCompanyInfo(), TextfileWindow::SetFontNames(), SetSettingValue(), ShowHelp(), ShowMissingContentWindow(), strecat(), CrashLog::WriteScreenshot(), and DriverFactoryBase::~DriverFactoryBase().
char* stredup | ( | const char * | s, |
const char * | last | ||
) |
Create a duplicate of the given string.
s | The string to duplicate. |
last | The last character that is safe to duplicate. If NULL, the whole string is duplicated. |
Definition at line 126 of file string.cpp.
References ttd_strnlen().
Referenced by ScriptScanner::AddFile(), TarScanner::AddFile(), ScriptInfo::AddLabels(), ScriptInfo::AddSetting(), Subsidy::AwardTo(), ScriptConfig::Change(), NetworkChatWindow::ChatTabCompletion(), CheckForMissingGlyphs(), CloneVehicleName(), CmdAlterGroup(), CmdCreateGoal(), CmdCreateStoryPage(), CmdCustomNewsItem(), CmdFoundTown(), CmdPlaceSign(), CmdRenameCompany(), CmdRenameDepot(), CmdRenameEngine(), CmdRenamePresident(), CmdRenameSign(), CmdRenameStation(), CmdRenameTown(), CmdRenameVehicle(), CmdRenameWaypoint(), CmdSetGoalProgress(), CmdSetGoalText(), CmdSetStoryPageTitle(), CmdTownSetText(), AIInfo::Constructor(), ScriptInfo::Constructor(), BaseConsist::CopyConsistPropertiesFrom(), CopyFromOldName(), CopyOutDParam(), CopyTempEngineData(), DetermineBasePaths(), DeterminePaths(), DisableStaticNewGRFInfluencingNonStaticNewGRFs(), DriverFactoryBase::DriverFactoryBase(), AIInfo::DummyConstructor(), ErrorMessageData::ErrorMessageData(), FileWriter::FileWriter(), BaseSet< T, Tnum_files, Tsearch_in_tars >::FillSetDetails(), FioOpenFile(), UnmappedChoiceList::Flush(), FormatString(), GamelogSetting(), GetFontByFaceName(), GetGRFPresetList(), IniLoadFile::GetGroup(), GRFConfig::GRFConfig(), GRFError::GRFError(), GRFFile::GRFFile(), IConsoleAliasRegister(), IConsoleCmdRegister(), IConsoleHistoryAdd(), IConsolePrint(), IniGroup::IniGroup(), IniItem::IniItem(), IniLoadSettingList(), IniLoadSettings(), IniSaveSettings(), IsGoodGRFConfigList(), LanguageStrings::LanguageStrings(), IniLoadFile::LoadFromDisk(), NetworkServerKickOrBanIP(), AfterNewGRFScan::OnNewGRFsScanned(), openttd_main(), ReadRawLanguageStrings(), ScriptScanner::RegisterScript(), ScriptConfig::ScriptConfig(), ErrorMessageData::SetDParamStr(), GameOptionsWindow::SetMediaSet(), AIConfig::SetSetting(), ScriptConfig::SetSetting(), SetSettingValue(), IniItem::SetValue(), SlError(), MusicDriver_ExtMidi::Start(), ScriptConfig::StringToSettings(), TranslateGRFStrings(), UpdateElement(), ScanProgressWindow::UpdateNewGRFScanStatus(), UpdateOSKOriginalText(), and StringNameWriter::WriteStringID().
|
inlinestatic |
Check if a string buffer is empty.
s | The pointer to the first element of the buffer |
Definition at line 59 of file string_func.h.
Referenced by FiosFileScanner::AddFile(), ServerNetworkAdminSocketHandler::AllowConnection(), CStrA::AppendStr(), CmdAlterGroup(), CmdCompanyCtrl(), CmdCreateGoal(), CmdCreateStoryPage(), CmdCustomNewsItem(), CmdFoundTown(), CmdGoalQuestion(), CmdPlaceSign(), CmdRenameCompany(), CmdRenameDepot(), CmdRenameEngine(), CmdRenamePresident(), CmdRenameSign(), CmdRenameStation(), CmdRenameTown(), CmdRenameVehicle(), CmdRenameWaypoint(), CmdSetGoalProgress(), CmdSetGoalText(), CmdSetStoryPageTitle(), CmdTownSetText(), NetworkContentListWindow::DrawDetails(), LandInfoWindow::DrawWidget(), AISettingsWindow::DrawWidget(), MusicTrackSelectionWindow::DrawWidget(), NetworkStartServerWindow::DrawWidget(), GenerateCompanyPasswordHash(), BlitterFactory::GetBlitterFactory(), ServerNetworkGameSocketHandler::GetClientName(), NetworkAddress::GetHostname(), GetKeyboardLayout(), GRFConfig::GetName(), GetSavegameFormat(), GRFLoadConfig(), IConsoleCmdExec(), IConsoleHistoryAdd(), InitializeMusic(), NetworkAddress::Listen(), LoadFreeTypeFont(), MakeScreenshotName(), NetworkAddress::NetworkAddress(), NetworkAutoCleanCompanies(), NetworkGameListAddItem(), NetworkGameListHandleDelayedInsert(), NetworkServerSetCompanyPassword(), NetworkStartUp(), NetworkGameWindow::NGameAllowedSorter(), SavePresetWindow::OnClick(), NetworkGameWindow::OnEditboxChanged(), NetworkContentListWindow::OnInvalidateData(), NewGRFWindow::OnInvalidateData(), CheatWindow::OnQueryTextFinished(), NewGRFParametersWindow::OnQueryTextFinished(), AISettingsWindow::OnQueryTextFinished(), TimetableWindow::OnQueryTextFinished(), GenerateLandscapeWindow::OnQueryTextFinished(), NetworkGameWindow::OnQueryTextFinished(), IndustryViewWindow::OnQueryTextFinished(), SpriteAlignerWindow::OnQueryTextFinished(), CreateScenarioWindow::OnQueryTextFinished(), OrdersWindow::OnQueryTextFinished(), SelectCompanyManagerFaceWindow::OnQueryTextFinished(), NetworkJoinStatusWindow::OnQueryTextFinished(), ScenarioEditorToolbarWindow::OnQueryTextFinished(), GameSettingsWindow::OnQueryTextFinished(), openttd_main(), FileStringReader::ParseFile(), ServerNetworkAdminSocketHandler::Receive_ADMIN_JOIN(), ServerNetworkGameSocketHandler::Receive_CLIENT_COMPANY_PASSWORD(), ServerNetworkUDPSocketHandler::Receive_CLIENT_FIND_SERVER(), ServerNetworkGameSocketHandler::Receive_CLIENT_GAME_PASSWORD(), ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(), ServerNetworkGameSocketHandler::Receive_CLIENT_MOVE(), ServerNetworkGameSocketHandler::Receive_CLIENT_NEWGRFS_CHECKED(), ServerNetworkGameSocketHandler::Receive_CLIENT_RCON(), ClientNetworkGameSocketHandler::Receive_SERVER_NEED_COMPANY_PASSWORD(), ClientNetworkGameSocketHandler::Receive_SERVER_NEED_GAME_PASSWORD(), ClientNetworkUDPSocketHandler::Receive_SERVER_NEWGRFS(), RenameSign(), NetworkAddress::Resolve(), SaveToHighScore(), BlitterFactory::SelectBlitter(), DriverFactoryBase::SelectDriver(), DriverFactoryBase::SelectDriverImpl(), SendChat(), ServerNetworkGameSocketHandler::SendCompanyInfo(), NetworkSocketHandler::SendCompanyInformation(), BaseMedia< Tbase_set >::SetSet(), MusicDriver_ExtMidi::Start(), TranslateGRFStrings(), LandInfoWindow::UpdateWidgetSize(), MusicTrackSelectionWindow::UpdateWidgetSize(), ValidatePlaylist(), and VerifyElementContentParameters().
int strnatcmp | ( | const char * | s1, |
const char * | s2, | ||
bool | ignore_garbage_at_front | ||
) |
Compares two strings using case insensitive natural sort.
s1 | First string to compare. |
s2 | Second string to compare. |
ignore_garbage_at_front | Skip punctuation characters in the front |
Definition at line 569 of file string.cpp.
References SkipGarbage().
Referenced by CargoSpecNameSorter(), EngineNameSorter(), GRFSorter(), VehicleGroupWindow::GroupNameSorter(), IndustryDirectoryWindow::IndustryNameSorter(), IndustryTypeNameSorter(), NetworkContentListWindow::NameSorter(), NewGRFWindow::NameSorter(), DropDownListStringItem::NatSortFunc(), NetworkGameWindow::NGameNameSorter(), SignList::SignNameSorter(), CompanyStationsWindow::StationNameSorter(), TownDirectoryWindow::TownNameSorter(), NetworkContentListWindow::TypeSorter(), and VehicleNameSorter().
bool strtolower | ( | char * | str | ) |
Convert a given ASCII string to lowercase.
NOTE: only support ASCII characters, no UTF8 fancy. As currently the function is only used to lowercase data-filenames if they are not found, this is sufficient. If more, or general functionality is needed, look to r7271 where it was removed because it was broken when using certain locales: eg in Turkish the uppercase 'I' was converted to '?', so just revert to the old functionality
str | string to convert |
Definition at line 320 of file string.cpp.
Referenced by GameScannerInfo::FindInfo(), AIScannerInfo::FindInfo(), GameScannerLibrary::FindLibrary(), AIScannerLibrary::FindLibrary(), FioFindFullPath(), FioFOpenFile(), FioOpenFile(), ScriptScanner::RegisterScript(), and SimplifyFileName().
bool StrValid | ( | const char * | str, |
const char * | last | ||
) |
Checks whether the given string is valid, i.e.
contains only valid (printable) characters and is properly terminated.
str | The string to validate. |
last | The last character of the string, i.e. the string must be terminated here or earlier. |
Definition at line 247 of file string.cpp.
References Utf8Decode(), and Utf8EncodedCharLen().
Referenced by LanguagePackHeader::IsValid().
|
inlinestatic |
Get the length of a string, within a limited buffer.
str | The pointer to the first element of the buffer |
maxlen | The maximum size of the buffer |
Definition at line 71 of file string_func.h.
Referenced by stredup().
|
inlinestatic |
Decode an UTF-16 character.
c | Pointer to one or two UTF-16 code points. |
Definition at line 195 of file string_func.h.
References Utf16DecodeSurrogate(), and Utf16IsLeadSurrogate().
|
inlinestatic |
Convert an UTF-16 surrogate pair to the corresponding Unicode character.
lead | Lead surrogate code point. |
trail | Trail surrogate code point. |
Definition at line 185 of file string_func.h.
Referenced by HandleCharMsg(), and Utf16DecodeChar().
|
inlinestatic |
Is the given character a lead surrogate code point?
c | The character to test. |
Definition at line 164 of file string_func.h.
Referenced by HandleCharMsg(), HandleIMEComposition(), and Utf16DecodeChar().
|
inlinestatic |
Is the given character a lead surrogate code point?
c | The character to test. |
Definition at line 174 of file string_func.h.
Referenced by HandleCharMsg().
|
inlinestatic |
Return the length of a UTF-8 encoded character.
c | Unicode character. |
Definition at line 99 of file string_func.h.
Referenced by CopyFromOldName(), FormatString(), Textbuf::InsertChar(), Textbuf::InsertString(), and Textbuf::UpdateSize().
size_t Utf8Decode | ( | WChar * | c, |
const char * | s | ||
) |
Decode and consume the next UTF-8 encoded character.
c | Buffer to place decoded character. |
s | Character stream to retrieve character from. |
Definition at line 437 of file string.cpp.
References GB(), and HasBit().
Referenced by Textbuf::DeleteChar(), FormatString(), Layouter::GetCharPosition(), GlobalVarChangeInfo(), Layouter::Layouter(), DefaultStringIterator::Next(), DefaultStringIterator::Prev(), StringFilter::SetFilterTerm(), str_fix_scc_encoded(), str_strip_colours(), str_validate(), StrValid(), and TranslateTTDPatchCodes().
size_t Utf8Encode | ( | char * | buf, |
WChar | c | ||
) |
Encode a unicode character and place it in the buffer.
buf | Buffer to place character. |
c | Unicode character to encode. |
Definition at line 477 of file string.cpp.
References GB().
Referenced by CheckForMissingGlyphs(), CopyFromOldName(), DrawNewsString(), UnmappedChoiceList::Flush(), FormatString(), Textbuf::InsertChar(), str_fix_scc_encoded(), and TranslateTTDPatchCodes().
|
inlinestatic |
Return the length of an UTF-8 encoded value based on a single char.
This char should be the first byte of the UTF-8 encoding. If not, or encoding is invalid, return value is 0
c | char to query length of |
Definition at line 118 of file string_func.h.
References GB().
Referenced by str_fix_scc_encoded(), str_validate(), StrValid(), TranslateTTDPatchCodes(), and Utf8TrimString().
|
inlinestatic |
Retrieve the previous UNICODE character in an UTF-8 encoded string.
s | char pointer pointing to (the first char of) the next character |
Definition at line 143 of file string_func.h.
Referenced by Textbuf::DeleteChar(), and DefaultStringIterator::Prev().
size_t Utf8StringLength | ( | const char * | s | ) |
Get the length of an UTF-8 encoded string in number of characters and thus not the number of bytes that the encoded string contains.
s | The string to get the length for. |
Definition at line 300 of file string.cpp.
Referenced by CmdAlterGroup(), CmdFoundTown(), CmdPlaceSign(), CmdRenameCompany(), CmdRenameDepot(), CmdRenameEngine(), CmdRenamePresident(), CmdRenameSign(), CmdRenameStation(), CmdRenameTown(), CmdRenameVehicle(), CmdRenameWaypoint(), GenerateCompanyName(), GeneratePresidentName(), and VerifyTownName().
size_t Utf8TrimString | ( | char * | s, |
size_t | maxlen | ||
) |
Properly terminate an UTF8 string to some maximum length.
s | string to check if it needs additional trimming |
maxlen | the maximum length the buffer can have. |
Definition at line 511 of file string.cpp.
References Utf8EncodedCharLen().
Referenced by NetworkAddChatMessage().
void ValidateString | ( | const char * | str | ) |
Scans the string for valid characters and if it finds invalid ones, replaces them with a question mark '?'.
str | the string to validate |
Definition at line 233 of file string.cpp.
References str_validate().
Referenced by ScriptInfo::AddLabels(), ScriptInfo::AddSetting(), and DetermineBasePaths().
int CDECL int CDECL vseprintf | ( | char * | str, |
const char * | last, | ||
const char * | format, | ||
va_list | ap | ||
) |
Safer implementation of vsnprintf; same as vsnprintf except:
str | buffer to write to up to last |
last | last character we may write to |
format | the formatting (see snprintf) |
ap | the list of arguments for the format |
Definition at line 50 of file string.cpp.
References min().
Referenced by CStrA::AddFormatL(), debug(), error(), Squirrel::ErrorPrintFunc(), grfmsg(), IConsolePrintF(), MidiSendCommand(), NetworkAddChatMessage(), Textbuf::Print(), Squirrel::PrintFunc(), seprintf(), ShowInfoF(), str_fmt(), and usererror().