MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / utf8TruncateCodePoints

Function utf8TruncateCodePoints

src/openrct2/core/String.cpp:683–698  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

681 }
682
683 std::string_view utf8TruncateCodePoints(std::string_view v, size_t size)
684 {
685 size_t i = 0;
686 while (i < v.size() && size > 0)
687 {
688 auto length = utf8GetCodePointSize(v.substr(i, v.size()));
689 if (!length.has_value())
690 {
691 return v.substr(0, i);
692 }
693 i += length.value();
694 size--;
695 }
696
697 return v.substr(0, i);
698 }
699
700 std::string urlEncode(std::string_view value)
701 {

Callers 1

setTextMethod · 0.85

Calls 3

utf8GetCodePointSizeFunction · 0.85
valueMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected