MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / SkipGarbage

Function SkipGarbage

src/string.cpp:410–417  ·  view source on GitHub ↗

* Skip some of the 'garbage' in the string that we don't want to use * to sort on. This way the alphabetical sorting will work better as * we would be actually using those characters instead of some other * characters such as spaces and tildes at the begin of the name. * @param str The string to skip the initial garbage of. * @return The string with the garbage skipped. */

Source from the content-addressed store, hash-verified

408 * @return The string with the garbage skipped.
409 */
410static std::string_view SkipGarbage(std::string_view str)
411{
412 Utf8View view(str);
413 auto it = view.begin();
414 const auto end = view.end();
415 while (it != end && IsGarbageCharacter(*it)) ++it;
416 return str.substr(it.GetByteOffset());
417}
418
419/**
420 * Compares two strings using case insensitive natural sort.

Callers 1

StrNaturalCompareFunction · 0.85

Calls 5

IsGarbageCharacterFunction · 0.85
substrMethod · 0.80
GetByteOffsetMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected