MCPcopy Create free account
hub / github.com/VCVRack/Rack / ellipsize

Function ellipsize

src/string.cpp:120–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118
119
120std::string ellipsize(const std::string& s, size_t maxCodepoints) {
121 if (maxCodepoints == 0)
122 return "";
123 std::string s2 = truncate(s, maxCodepoints);
124 if (s2 == s)
125 return s;
126 // If string was truncated, back up a codepoint and add a Unicode ellipses character
127 size_t pos = UTF8PrevCodepoint(s2, s2.size());
128 return s2.substr(0, pos) + "…";
129}
130
131
132std::string ellipsizePrefix(const std::string& s, size_t maxCodepoints) {

Callers 3

loadStringMethod · 0.85
stepMethod · 0.85
stepMethod · 0.85

Calls 3

truncateFunction · 0.85
UTF8PrevCodepointFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected