MCPcopy Create free account
hub / github.com/LibreSprite/LibreSprite / utf8_icmp

Function utf8_icmp

src/base/string.cpp:200–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198}
199
200int utf8_icmp(const std::string& a, const std::string& b, int n)
201{
202 utf8_const_iterator a_it(a.begin());
203 utf8_const_iterator a_end(a.end());
204 utf8_const_iterator b_it(b.begin());
205 utf8_const_iterator b_end(b.end());
206 int i = 0;
207
208 for (; (n == 0 || i < n) && a_it != a_end && b_it != b_end; ++a_it, ++b_it, ++i) {
209 int a_chr = std::tolower(*a_it);
210 int b_chr = std::tolower(*b_it);
211
212 if (a_chr < b_chr)
213 return -1;
214 else if (a_chr > b_chr)
215 return 1;
216 }
217
218 if (n > 0 && i == n)
219 return 0;
220 else if (a_it == a_end && b_it == b_end)
221 return 0;
222 else if (a_it == a_end)
223 return -1;
224 else
225 return 1;
226}
227
228} // namespace base

Callers 7

TESTFunction · 0.85
getCommandByNameMethod · 0.85
FontPopupMethod · 0.85
onProcessMessageMethod · 0.85

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by 1

TESTFunction · 0.68